Ubuntu/How to upgrade from PHP 7.0 to PHP 7.1

From Mana zināšanu grāmata
Revision as of 10:41, 16 April 2026 by Kaspars (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Install PHP 7.1

Lets stop our server first, then install PHP 7.1.

$ service apache2 stop
$ sudo apt-get install php7 php7.1

We'll also install some extra packages for our PHP installation - these are needed for Laravel and Composer!

$ sudo apt-get install php7.1-curl php7.1-xml php7.1-zip php7.1-gd php7.1-mysql php7.1-mbstring

Once that is done, lets check PHP is updated on the CLI

$ php -v

If the first row looks like this, we've done good so far! PHP 7.1.11-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Oct 27 2017 13:49:56) ( NTS )

Remove PHP 7.0

Now we have PHP7.1, lets get rid of PHP7.0

$ sudo apt-get purge php7.0 php7.0-common

Make PHP7.1 used by Apache

Finally, we need to tell Apache to use PHP7.1 now PHP 7.0 is not being used. Lets enable the PHP mod!

$ a2enmod php7.1
$ service apache2 restart