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

1
2
3
4
5
6
7
8
9
10
11
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

1
2
3
4
5
6
7
8
9
10
11
12
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模块

1
2
3
4
5
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

继续编译

1
2
3
4
5
6
7
8
9
10
11
12
. /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"   


 本文转自 ninnycalf 51CTO博客,原文链接:http://blog.51cto.com/314258/1859842


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值