- Create backups for all Nginx files.
"cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx_old" "cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.old"
- Download all sources and dependencies for Nginx
#You can check previous configuration parameters by nginx -V #Download all needed sources wget http://nginx.org/download/nginx-1.6.3.tar.gz wget https://github.com/pagespeed/ngx_pagespeed/archive/v184.108.40.206-beta.tar.gz wget https://github.com/openresty/headers-more-nginx-module/archive/v0.28.tar.gz nginx-headers.tar.gz wget https://dl.google.com/dl/page-speed/psol/220.127.116.11.tar.gz #Extract them tar -zxvf file.tar.gz
- Configure the compilation with custom parameters. You can even specify another binary location for the newly compiled software. In this way, all the installed software will sill exist in the original location. In my case, I decided to overwrite the existing binary of Nginx.
./configure --add-module=/home/ec2-user/headers-more-nginx-module-0.28 --add-module=/home/ec2-user/ngx_pagespeed-18.104.22.168-beta --with-http_ssl_module
- Compile and install
sudo make sudo make test #run: "make install clean" This will install the new binary in place of the old one and makes a backup of the old one. sudo make install
- Sometimes this step is a little bit risky because some files may be opened and could not be overwritten. In my case, everything worked fine. Even if the service was running in this time, the binary was already replaced.
- If you decided to go on a safer way and installed the binary in another place, now all you have to change is defining your daemon to use this binary instead of the old one, test the Nginx configuration and restart the service.
A much more complex approach may be found here