Ubuntu system nginx upgrade version

Step 1: Stop the original service and back up the directory

sudo service nginx stop
sudo cp -r /etc/nginx ./var/bak/

Step 2: Uninstall the original nginx
sudo apt-get remove nginx
If you need to delete it completely, add a –purge parameter

sudo apt-get --purge remove nginx

Step 3: Update ubuntu source file /etc/apt/sources.list
#Enter directory
cd /etc/apt
backup source file
$sudo cp sources.list sources.list.bak
#Edit configuration file
sudo vim sources.list
#End of file Add the following two lines and save
deb http://nginx.org/packages/ubuntu/ codename nginx
deb-src http://nginx.org/packages/ubuntu/ codename nginx
Among them, it should be noted that the codename should be replaced by ubuntu The version of the system, where:

14.04 corresponds to trusty

16.04 corresponds to xenial and we are this

17.10 corresponds to artful

18.04 corresponds to bionic

Because I am using the 16.04 version of ubuntu, here is replaced by

deb http://nginx.org/packages/ubuntu/ xenial nginx
deb-src http://nginx.org/packages/ubuntu/ xenial nginx
imports the key file needed by nginx

sudo wget http://nginx.org/keys/nginx_signing.key
sudo apt-key add nginx_signing.key

The fourth step is to update the source and install nginx
sudo apt-get update
sudo apt-get install nginx
Use the nginx -v command to view the installed version.

The fifth step is to copy the configuration files to the newly installed program directory
sudo cp /var/bak/nginx/conf.d/. /etc/nginx/conf.d
sudo cp /var/bak/nginx/nginx.conf / etc/nginx/

The sixth step is to start the new nginx service
sudo service nginx start
At this point, the operation of upgrading nginx to the latest version under ubuntu is completed.

Guess you like

Origin blog.csdn.net/weixin_45314962/article/details/130848842