Nginx and PageSpeed build from source CentOS example
Putting this down for my own future reference. I've tried following the installation guide at https://modpagespeed.com/doc/buildngxpagespeedfromsource to install Nginx and PageSpeed on my new DigitalOcean CentOS 7 droplet with this command
bash <(curl -f -L -sS https://ngxpagespeed.com/install) --nginx-version latest
but keep encountering the error message such as
checking for psol
cc: error: /root/ngxpagespeed-latest-stable/psol/lib/Release/linux/x64/pagespeedautomatic.a: No such file or directory
Apparently, the script at https://ngxpagespeed.com/install will download the latest tarball, but it does not have the x64
directory in it and will cause checking for psol not found error later
.
For CentOS, the stable release as of the time of writing is still version 1.11.33.4. You can specify the script to use version 1.11.33.4 as well with this command
bash <(curl -f -L -sS https://ngxpagespeed.com/install) --nginx-version 1.13.1 --ngx-pagespeed-version 1.11.33.4
and when prompted for the options, add:
--with-httpsslmodule --prefix=/usr/local/share/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/local/sbin --error-log-path=/var/log/nginx/error.log
NOTE: Please modify the options to suit your own configuration
By the end of the script execution, you should see this message
Nginx installed with ngx_pagespeed support compiled-in.
If this is a new installation you probably need an init script to manage starting and stopping the nginx service. See: http://wiki.nginx.org/InitScripts
You'll also need to configure ngx_pagespeed if you haven't yet: https://developers.google.com/speed/pagespeed/module/configuration
If you prefer to do it manually, see the steps below.
The following steps are my own to get Nginx and PageSpeed module build from scratch. You might have to modify the directories to suit your own configuration.
wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.11.33.4-beta.zip
unzip v1.11.33.4-beta.zip
cd ngx_pagespeed-1.11.33.4-beta/
NPS_VERSION=1.11.33.4
psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
wget ${psol_url}
tar -xzvf 1.11.33.4.tar.gz
Download latest nginx version from http://nginx.org/en/download.html
At this time of writing, the version is 1.13.1. Download and unzip.
cd nginx-1.13.1/
Enter this command:
./configure --add-module=$HOME/ngx_pagespeed-${NPS_VERSION}-beta --with-http_ssl_module \ --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
yum remove nginx* -- this is optional
Depending on how you configure the make, the compiled Nginx executable is located at
/usr/local/sbin
vi /etc/nginx/nginx.conf
Add these lines to the http block.
## #ngx_pagespeed module settings ## pagespeed on; pagespeed FileCachePath /var/ngx_pagespeed_cache;
Go to
/usr/local/sbin
and start Nginx.Point the browser to the droplet's IP address and the Nginx welcome page will appear if everything goes smoothly.
See also : Nginx + FastCGI + Go Setup.
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+9k Golang : How to control fmt or log print format?
+17.8k Golang : Check if a directory exist or not
+20.8k Golang : Clean up null characters from input data
+6.4k Golang : Warp text string by number of characters or runes example
+14k Golang : Get uploaded file name or access uploaded files
+5.8k nginx : force all pages to be SSL
+13.1k Golang : error parsing regexp: invalid or unsupported Perl syntax
+7.9k Golang : Find relative luminance or color brightness
+7.2k Golang : How to stop user from directly running an executable file?
+4.4k Adding Skype actions such as call and chat into web page examples
+5.8k Fix ERROR 2003 (HY000): Can't connect to MySQL server on 'IP address' (111)
+14.6k Golang : Basic authentication with .htpasswd file