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
+11.2k Golang : Handle API query by curl with Gorilla Queries example
+11.3k Golang : How to detect a server/machine network interface capabilities?
+24k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+20.5k Golang : Clean up null characters from input data
+19.2k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+9.8k Golang : Text file editor (accept input from screen and save to file)
+21.4k Golang : How to reverse slice or array elements order
+7.1k Golang : Dealing with struct's private part
+6.9k Golang : Example of custom handler for Gorilla's Path usage.
+12.2k Golang : Transform comma separated string to slice example
+9.5k Golang : Get current, epoch time and display by year, month and day
+10.4k Golang : Get currencies exchange rates example