添加PageSpeed模块安装nginx

我喜欢在Ubuntu上将Google PageSpeed模块添加到我的nginxnetworking服务器。

这个链接提供了一个简单的https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source?hl=de的概述,但是它只涵盖了从头开始安装nginx的情况。

我已经安装了nginx,当我在/ var / lib / nginx文件夹中input以下命令行时,出现“No such file”错误:

./configure --add-module=$HOME/ngx_pagespeed-release-1.7.30.4-beta 

在这个问题上你最好的select是从零开始构buildNginx。

保存你的nginxconfiguration文件到一个安全的地方,然后做,假设你在Debian中:

 sudo dpkg -r nginx 

如果你在Debian中: sudo apt-get install build-essential zlib1g-dev libpcre3-dev

只要确保你移除了Nginx,并且得到了所需的libs来构buildNginx,如果不在Debian中的话。

库和工具是:

 gcc-c++ pcre zlib make wget 

接下来的部分是系统独立的。

获取最新的Nginx版本:

 cd /usr/src/ sudo wget http://nginx.org/download/nginx-1.7.6.tar.gz sudo tar xvfvz nginx-1.7.6.tar.gz cd /usr/src/nginx-1.7.6 

获取最新的pagespeed源码:

 sudo wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.9.32.1-beta.zip 

首先解压模块:

 sudo unzip v1.9.32.1-beta.zip cd ngx_pagespeed-1.9.32.1-beta 

Wget模块目录中的PSOL库,并在那里解压缩它们:

 sudo wget wget https://dl.google.com/dl/page-speed/psol/1.9.32.1.tar.gz sudo tar xvfvz 1.9.32.1.tar.gz 

cd回到nginx的源代码目录并configurationmake和make install。 确保将configuration阶段的Nginx用户更改为适合您需要的用户(–user = nginx –group = nginx):

 cd /usr/src/nginx-1.7.6 ./configure --add-module=/usr/src/nginx-1.7.6/ngx_pagespeed-1.9.32.1-beta --prefix=/usr/local/nginx --sbin-path=/usr/local/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/run/nginx.pid --lock-path=/run/lock/subsys/nginx --user=nginx --group=nginx 

configuration阶段完成时:

 sudo make sudo make install 

这将带给你最后一个Nginx版本的最后一个页面速度模块和库准备好摇滚。

你可以使用一个自定义的PPA来安装nginx的Pagespeed到你的系统。

查看https://launchpad.net/~sandyd/+archive/nginx-current-pagespeed进行自定义构build。