Upgrading major versions of Nginx,Mysql
Upgrading Version of Nginx
Login to Server (on which need to update Nginx version)
• Cd /home/neal/root/
Download the nginx source
• wget http://nginx.org/download/nginx-1.18.0.tar.gz
Unzip the downloaded file
• tar xzvf filename
• Nginx –V
Copy the configuration modules in text
Open the server with latest SSL version (demo.apoyar)
• Nginx –V
Copy the last configuration command with SSL and paste it in text document at last
Download the open SSL source
• Go to cd /usr/local/src/
• wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
• tar xzvf filename
• go to cd root/
• go to nginx folder
Paste here that configuration module which we have in text document and hit enter
NOTE: - If getting any errors, troubleshoot with the below steps as per errors coming across.
If the ./configure gives you any errors, take the following steps:
apt-get install uuid-dev
If ./configure gives you an error about psol not found
apt-get install libgd-dev in case of this error:
./configure: error: the HTTP image filter module requires the GD library.
apt-get install libgeoip-dev in case of:
./configure: error: the GeoIP module requires the GeoIP library.
install libssl-dev in case of:
./configure: error: SSL modules require the OpenSSL library.
install libpcre++-dev in case of:
./configure: error: the HTTP rewrite module requires the PCRE library.
apt-get install libxslt1-dev in case of:
./configure: error: the HTTP XSLT module requires the libxml2/libxslt
apt-get install zlib1g-dev ./configure: error: the HTTP gzip module requires the zlib library
apt-get install libpam0g-dev in case of: make gives you an error:
fatal error: security/pam_appl.h: No such file or directory
Then run below command
• make
Uninstall OLD Nginx
• Cd etc/
• tar czvf nginx
• mv nginx /root/
• dpkg – I l grep nginx
• apt-get purge nginx
After removing old nginx reboot the server
Installing NEW Nginx
• Cd /root/nginx 1.18.0
• Nginx –v
If the nginx command doesn't work, create a symlink:
• ln -s /usr/share/nginx/sbin/nginx /usr/sbin/Ln
• Nginx –V
• Go to cd etc/
• tar xzvf nginx 1.18.0
Go to Cd /nginx/sites-enabled
Check syntax and potential errors:
• sudo nginx –t
- Will throw this error nginx: [emerg] mkdir() "/var/lib/nginx/body" failed (2: No such file or directory)
- Just create directory
• mkdir -p /var/lib/nginx && sudo nginx –t
Create systemd unit file for NGINX:
• sudo vim /etc/systemd/system/nginx.service
Copy/paste the following content:
NOTE: The location of the PID file and the NGINX binary may be different depending on how NGINX was compiled.
[Unit]
Description=A high performance web server and a reverse proxy server After=network.target
[Service] Type=forking PIDFile=/run/nginx.pid ExecStartPre=/usr/sbin/nginx -t -q -g 'daemon on; master_process on;' ExecStart=/usr/sbin/nginx -g 'daemon on; master_process on;' ExecReload=/usr/sbin/nginx -g 'daemon on; master_process on;' -s reload ExecStop=-/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid TimeoutStopSec=5 KillMode=mixed
[Install] WantedBy=multi-user.target
Start and enable NGINX service:
• sudo systemctl start nginx.service && sudo systemctl enable nginx.service
Create UFW NGINX application profile:
• sudo vim /etc/ufw/applications.d/nginx
Copy/paste the following content:
[Nginx HTTP] title=Web Server (Nginx, HTTP) description=Small, but very powerful and efficient web server ports=80/tcp
[Nginx HTTPS] title=Web Server (Nginx, HTTPS) description=Small, but very powerful and efficient web server ports=443/tcp
[Nginx Full] title=Web Server (Nginx, HTTP + HTTPS) description=Small, but very powerful and efficient web server ports=80,443/tcp
Now, verify that UFW app profiles are created and recognized:
• sudo ufw app list
- Available applications:
# Nginx Full # Nginx HTTP # Nginx HTTPS # OpenSSH