By ramstete
Hello, I have read many answers here, but my goal it is to install the pagespeed on ubuntu without make disasters. I have see that need to “reinstall” the nginx, but is it possible using the packages system? And which are the steps to do withotu to risk to lose the existing web portal?
Thank you very much and sorry for my poor english
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Unfortunately, the pagespeed module is not available from the official page repositories. In order to use it with Nginx, you’ll need to build Nginx from source. These directions are based on the ones from the ngx_pagespeed Google Code page, but they have been somewhat changed to be a better drop in replacement for the packaged version.
First install the build dependencies:
sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip
Then download ngx_pagespeed:
cd
NPS_VERSION=1.9.32.1
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip
unzip release-${NPS_VERSION}-beta.zip
cd ngx_pagespeed-release-${NPS_VERSION}-beta/
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
tar -xzvf ${NPS_VERSION}.tar.gz # extracts to psol/
Now we’ll build Nginx with the pagespeed module (note the configure arguments are different from the version provided by upstream):
cd
# check http://nginx.org/en/download.html for the latest version
NGINX_VERSION=1.6.1
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
tar -xvzf nginx-${NGINX_VERSION}.tar.gz
cd nginx-${NGINX_VERSION}/
./configure --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta \
--prefix=/usr/local/share/nginx --conf-path=/etc/nginx/nginx.conf \
--sbin-path=/usr/local/sbin --error-log-path=/var/log/nginx/error.log
make
sudo make install
It should now be installed and available. Before removing the old Nginx package, we need to do one more thing. Let’s copy the init script that comes with the package and modify it to work with the new version:
cp /etc/init.d/nginx /etc/init.d/nginx-pagespeed
sed -i 's|/usr/sbin/nginx|/usr/local/sbin/nginx|g' /etc/init.d/nginx-pagespeed
Now remove the package:
sudo apt-get remove nginx*
Finally, enable pagespeed by adding the following to /etc/nginx/nginx.conf
##
#ngx_pagespeed module settings
##
pagespeed on;
pagespeed FileCachePath /var/ngx_pagespeed_cache;
And start it with:
service nginx-pagespeed start
This is out of date; there’s now an automated installer for ngx_pagespeed: build_ngx_pagespeed_from_source
It’s also suggesting people build ngx_pagespeed version 1.9, which has unpatched security vulnerabilities in HTTPS fetching.
This comment has been deleted
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.