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
+9.2k Golang : Get all countries currencies code in JSON format
+11.8k Golang : Decompress zlib file example
+8.8k Golang : Capture text return from exec function example
+7k Golang : Accessing dataframe-go element by row, column and name example
+5.4k Unix/Linux/MacOSx : Get local IP address
+27.3k PHP : Count number of JSON items/objects
+13.5k Golang : unknown escape sequence error
+10.6k Nginx : TLS 1.2 support
+12.7k Swift : Convert (cast) Int to String ?
+8.5k Golang : Executing and evaluating nested loop in html template
+6.9k Golang : Dealing with postal or zip code example
+24.6k Golang : Generate MD5 checksum of a file