nginx加載ngx_pagespeed

1、下載ngx_pagespeed

github  https://github.com/pagespeed/ngx_pagespeed

wget https://github.com/pagespeed/ngx_pagespeed/archive/latest-stable.tar.gz

tar zxvf latest-stable.tar.gz
[root@web ngi]# ll ngx_pagespeed-latest-stable
total 129720
-rw-rw-r-- 1 root   root     12306 Sep 16 03:18 config
-rw-rw-r-- 1 root   root       284 Sep 16 03:18 config.make
-rw-rw-r-- 1 root   root      2881 Sep 16 03:18 cpp_feature
-rw-rw-r-- 1 root   root     11342 Sep 16 03:18 LICENSE
-rw-rw-r-- 1 root   root      1474 Sep 16 03:18 README.md
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 scripts
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 src
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 test

2、下載pagespeed

wget https://dl.google.com/dl/page-speed/psol/1.11.33.4.tar.gz

tar zxvf 1.11.33.4.tar.gz -C ngx_pagespeed-latest-stable
[root@web ngi]# ll ngx_pagespeed-latest-stable
total 129720
-rw-rw-r-- 1 root   root     12306 Sep 16 03:18 config
-rw-rw-r-- 1 root   root       284 Sep 16 03:18 config.make
-rw-rw-r-- 1 root   root      2881 Sep 16 03:18 cpp_feature
-rw-rw-r-- 1 root   root     11342 Sep 16 03:18 LICENSE
drwxr-x--- 4 163798 5000      4096 Sep 15 21:57 psol
-rw-rw-r-- 1 root   root      1474 Sep 16 03:18 README.md
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 scripts
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 src
drwxrwxr-x 2 root   root      4096 Sep 16 03:18 test

3、在nginx目錄增加page-speed模塊

cd nginx-1.2.0
./configure --user=web --group=web --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-md5=/usr/lib --with-sha1=/usr/lib --add-module=../ngx_pagespeed-latest-stable
會出現下面錯誤
build_from_source=false
error: module ngx_pagespeed requires the pagespeed optimization library

4、需要升級gcc,下面轉一個簡單點的方法

cd /etc/yum.repos.d && wget http://people.centos.org/tru/devtools-2/devtools-2.repo
然後
yum -y install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++
這個將安裝的文件放在了
/opt/rh/devtoolset-2

繼續編譯

./configure --user=web --group=web --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-md5=/usr/lib --with-sha1=/usr/lib --add-module=../ngx_pagespeed-latest-stable --with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc
make
如果你是在線編譯就可以不用make install
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/oldnginx
cp objs/nginx /usr/local/nginx/sbin/
查看一下是否正確
/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
接下來就可以重啓了
sudo make upgrade
/usr/local/nginx/sbin/nginx -s reload



fix1、臨時更改環境變量

export PATH="/opt/rh/devtoolset-2/root/usr/bin:$PATH"  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章