I’ve been going over the community questions and I’ve noticed one constant theme. Every now and then a question regarding the upgrade of a PHP version appears.
As such I’ve decided to create this question so it can be easily found and it’s universal, at least for Ubuntu-based droplets using Nginx.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Sign up for Infrastructure as a Newsletter.
Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
The first thing I want to mention is, you can’t directly upgrade a PHP version from let’s say 7.1 to 7.4. Having said that you can install a new one and start using it.
Firstly, to be able to install a certain PHP version, in this case, 742 you’ll need to add a certain repository to your system
Update the repository index.
Install PHP 7.4 with the below command.
To install extensions run
The above is the required extensions for a WordPress installation that’s why I’m posting them. Having said that it’s good to have these extensions as well.
That’s it, you now have your new PHP version installed.
Now we need to make it a default for your Droplet and Application.
Find: cgi.fix_pathinfo. Remove semi-colon and set 0
Save the file, exit, and execute
Next configure Nginx to use the new PHP we installed
Find the block
Save the file, exit, and execute
You can now test php by using
phpinfo()
function or usephp -v
command into the terminal.