Hi there,

I would like to Update NGINX & PHP & Ubuntu to the current version’s.

**Current: **
**Server Info: nginx/1.14.0
PHP Version: 7.0.33-14+ubuntu16.04.1+deb.sury.org+1 *
*

I have already used google but in this constellation, but i haven’t figured it out clear -

How is the right way?

Would be very happy if someone could give me a tip

many thanks in advance

Daniel

edited by bobbyiliev

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
1 answer

Hi @danielmire,

Nginx
Regarding Nginx, upgrading is fairly easy and usually doesn’t break anything. You need to add a new repo, then Nginx can be upgraded every time you run your sudo apt upgrade command.

The first steps you’ll want to do is backing up your current NGINX configs. You can run these two commands to create a backup directory and copy your config files over to it:

sudo mkdir /etc/nginx-backup/
sudo cp -r /etc/nginx/* /etc/nginx-backup/

Next we need to add the repository. For this, you’ll need to install software-properties-common if it’s not already installed. Run this command to make sure it is installed:

sudo apt-get install software-properties-common

Now we’ll add the NGINX repo by running these commands:

nginx=stable
sudo add-apt-repository ppa:nginx/$nginx

Once done, you’ll need to update your system like so

sudo apt-get update
sudo apt-get full-upgrade

You’ll be prompted to use a new config files twice, you’ll want to answer N to those for now to keep your current version.

Now when you run sudo nginx -v you should see a new version.

Finally, you’ll want to edit your /etc/nginx/nginx.conf file and add this line just below the pid line near the top:

include /etc/nginx/modules-enabled/*.conf;

Next, run sudo nginx -t to test the new config and make any changes you need in order for it to pass the test.

Then restart your nginx service and you are good to go.

PHP

In this case rather than updating, you’ll just install a higher PHP version on your droplet.

Here are the steps, if you are on an Ubuntu.

Update Packages

Make sure your Ubuntu server is having the latest packages by running the following command.

sudo apt update
sudo apt upgrade

Add a repository for PHP 7.3

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.3-fpm

Extensions

PHP with it’s extensions is useless so you’ll need to install them regardless which Web Service you are using. The next command will include the most common extensions

sudo apt install php7.3-common php7.3-mysql php7.3-xml php7.3-xmlrpc php7.3-curl php7.3-gd php7.3-imagick php7.3-cli php7.3-dev php7.3-imap php7.3-mbstring php7.3-opcache php7.3-soap php7.3-zip php7.3-intl -y 

If you need to add another one, just type in

sudo apt install php7.3-nameofextension

And you are ready, you now have the latest PHP version on your droplet.

Regards,
KDSys

Submit an Answer