How to install PHP 7.2.latest on Ubuntu 16.04/ Ubuntu 18.04/Debian etc/
I have a number of guides on moving away from CPanel, Setting up VM’s on UpCloud, AWS, Vultr or Digital Ocean along with installing and managing WordPress from the command line. PHP is my programming language of choice.
PHP has a support page that declares the support date ranges and support types: http://php.net/supported-versions.php
A version of PHP is either actively supported, security fix supported or end of life. Read this post to check WordPress for PHP compatibility.
From time to time vulnerabilities come up that require PHP updates to be applied.
Multiple flaw found in #PHP, most severe of which could allow arbitrary code execution
PHP 7.2 —prior to 7.2.5
PHP 7.1 —prior to 7.1.17
PHP 7.0 —prior to 7.0.30
PHP 5.0 —prior to 5.6.36https://t.co/TtiqXePoHu
Upgrade to the latest version of PHP immediately
— The Hacker News (@TheHackersNews) May 1, 2018
— Neustradamus (@neustradamus) November 9, 2018
Source Link here
I have guides on setting up PHP 7 here on Digital Ocean, here on AWS and here on Vultr. I have tried upgrading to PHP 7.1 in the past with no luck (I forgot to change something and rolled back to 7.0).
FYI: I have a guide on setting up PHP child workers so the output from some commands below may be different than yours. Here are the steps I performed to install PHP 7.2 alongside 7.0 then switch. to 7.2.
Backup your system
Note: Use this information at your own risk.
Updating php 7.2.12 to 7.2.12
Update your Ubuntu systems
Updating from an older php (e.g 5.x, 7.1, 7.1 to say 7.2.12)
This software provides an abstraction of the used apt repositories. It allows you to easily manage your distribution and independent software vendor software sources. More Info
Add the main PHP repo (more information)
Update the package lists
“In a nutshell,
apt-get update doesn’t actually install new versions of the software. Instead, it updates the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories.” from here
List Installed Packages (optional)
Install PHP 7.2
Install common PHP modules
Install PHP FPM
Update all packages (may be needed to update from php 7.2.4 to 7.2.5)
Edit your NGINX sites-available config
Edit your NGINX sites-enabled config
I edited these lines
Edit your PHP config (and make desired changes)
Edit your PHP pool config file (as required). See this guide here.
> max_input_vars = 1000
> memory_limit = 1024M
> max_file_uploads = 8M
> post_max_size = 8M
Make sure you set: listen = /run/php/php7.2-fpm.sock
Set PHP 7.2 as the default PHP
Check your PHP version
Check the status of your PHP (and child workers)
Check your website.
Guides that helped me.
Check your log files
Debug FPM Service
Remove PHP 7.0
PHP 7.0 Removed 🙂
Remove other unused packages
At the time of writing (November the 18th 2018) PHP 7.2.12 is the latest version of PHP and PHP 7.3 will be out at the end of the year.
Good luck and I hope this guide helps someone
Ask a question or recommend an article
[contact-form-7 id=”30″ title=”Ask a Question”]
v1.4 Updated the post to mention PHP 7.0 EOL
v1.3 Updated to add PHP 7.2.12 information
v1.2 PHP 7.2.9 and PHP 7.2 updates
v1.1 Remove PHP 7.0 steps
v1.0 Initial post