1、安装好nginx或者tengine
2、下载pagespeed模块并且解压
sudo mkdir -p /usr/local/tengine/modules
wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.7.30.3-beta.tar.gz
sudo tar xvfvz v1.7.30.3-beta.tar.gz -C /usr/local/tengine/modules –no-same-owner
3、下载PSOL优化库
wget https://dl.google.com/dl/page-speed/psol/1.7.30.3.tar.gz
sudo tar xvfz 1.7.30.3.tar.gz -C /usr/local/tengine/modules/ngx_pagespeed-1.7.30.3-beta –no-same-owner
4、加载pagespeed模块
/usr/local/tengine/sbin/dso_tool –add-module=/usr/local/tengine/modules/ngx_pagespeed-1.7.30.3-beta/
5、查看是否安装成功
ls /usr/local/tengine/module (列出ngx_pagespeed.so 表示安装成功)
6、编辑nginx.conf配置文件支持pagespeed
dso {
load ngx_http_concat_module.so;
load ngx_http_sysguard_module.so;
load ngx_pagespeed.so;
}
…
…
Server {
listen 80;
index index.html index.php;
server_name xxx.xxx.xxx;
pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
}
7、检查配置文件 并且重新加载nginx
nginx -t
service nginx reload
(注意:此种方法为动态模块编译,可以nginx -V 查看,不需要再次configure、make nginx,还可以在安装nginx的时候直接./configure –add-module=/usr/local/tengine/ngx_pagespeed-1.7.30.3-beta进行直接配置)
参考:https://zhangge.net/5063.html