cd /usr/local/src wget https://github.com/apache/incubator-pagespeed-ngx/archive/v1.13.35.2-stable.tar.gz tar xzvf v1.13.35.2-stable.tar.gz cd incubator-pagespeed-ngx-1.13.35.2-stable wget https://dl.google.com/dl/page-speed/psol/1.13.35.2-x64.tar.gz tar -xzvf 1.13.35.2-x64.tar.gz /www/server/nginx/sbin/dso_tool --add-module=/usr/local/src/incubator-pagespeed-ngx-1.13.35.2-stable
查看模块
ls /usr/local/tengine/module (列出ngx_pagespeed.so 表示安装成功)
编辑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;
}
检查配置文件 并且重新加载nginx
nginx -t
service nginx reload
测试效果
搜索下 pagespeed,可以看到,大部分源码已经被替换