WordPress is built with the PHP scripting language, so it is very important to have the latest version installed on your web server. It’s easy to keep WordPress up to date, but core technologies (like PHP) are not always in sync with your installed version of WordPress.
This is especially true for homemade web servers that you set up yourself. If the server hosting your site is not up to date, PHP is unlikely to get updated, which could leave your site vulnerable to exploits or faulty functionality. This means you need to update PHP in order for everything to work – here’s how to update PHP in WordPress.
Check your current PHP version
From time to time, the minimum supported PHP version that WordPress supports changes. You can check the current minimum version on the WordPress website, but at the time of posting, WordPress currently supports at least PHP 7.3 or higher.
However, not all web servers will run PHP 7.3 or higher. Older PHP versions will still work with WordPress, but this may cause new themes, plugins and features to crash.
To make sure you are using the correct PHP version, you can check your current WordPress installation using the Site Status menu in WordPress 5.2 and up.
- To do this, log in with WordPress admin rights. page. You need a user account that has the administrator role applied. Once logged in, click on “Tools”> “Site Status” in the sidebar.
- If your WordPress PHP version is out of date, it will be listed as a recommendation in the Status tab.
- To check the current PHP version, click Info> Server and check the version listed in the PHP Version category.
You can also check your PHP version using third party plugins such as PHP Compatibility Checker If your PHP version is out of date, you will need to update it as soon as possible.
– / –
Back up your site and prepare to upgrade
Updating a core component like PHP can break your site. Before rushing to update PHP in WordPress, it’s best to back up your WordPress site and get ready to update it.
You should start by making a copy of your MySQL database and physical copies of your WordPress files. Many WordPress hosting providers offer built-in backup services that you can take advantage of, so be sure to check with your web host if this is the case.
In the case of DIY servers, it’s your responsibility – manual backups will be required. If you’re afraid of getting into the terminal, use a plugin like UpdraftPlus to automatically create regular backups of your WordPress installation automatically. UpdraftPlus can store your backups from your server using cloud storage services such as Google or Microsoft Azure.
Once your WordPress site has been backed up, you are ready to take the plunge and start updating PHP in WordPress.
Switch PHP versions in WordPress with cPanel
Many web hosting services use the cPanel web hosting control panel system so that you can monitor and make changes to your web hosting. For a shared hosting where you share your web space with other users, you may not be able to upgrade PHP in WordPress at all, but you can switch to a newer version if available.
If not, talk directly to your hosting provider about updating PHP to the latest version. If so, cPanel allows you to quickly and easily switch to newer versions of mission-critical server software like PHP.
Since cPanel is modular, these settings may differ depending on your own version of cPanel.
- To switch PHP to a newer version in cPanel, log into the cPanel site for your web host. Once logged in, find the cPanel options named “PHP Selector” or “Select PHP Version” and click them.
- The PHP Selector tool allows you to change the version of PHP that is currently in use on your server. From the “PHP version” drop-down menu, select a version equal to or greater than the minimum supported by WordPress (currently PHP 7.3), then click “Set as current” to apply it.
The PHP version running on your server should change immediately. There are other web hosting control panels that can support similar functionality – if they don’t exist and you have access to the web server directly, you can manually update PHP.
Manually update PHP from a terminal or SSH connection
This option can and should only be used by users who have backed up their site and feel comfortable using the Linux terminal. Most web servers run Linux, but if you have a Windows IIS server, you can update PHP in WordPress using the web platform installer.
As we mentioned, it is very important that you have a backup of your WordPress site before you start. It is also worth testing the latest PHP version on a test version of WordPress on a separate server and installing to make sure your plugins, themes, and general WordPress setup work correctly with it before upgrading your main server.
- When you’re ready to upgrade, open a terminal on your local web server, or connect to a remote server using an SSH client on Windows, Linux, or macOS. Once connected, check your PHP version by typing php -v and pressing Enter.
- For Ubuntu and Debian servers, enter sudo apt-get install software-properties-common && sudo add-apt-repository ppa: ondrej / php && sudo apt update && sudo apt install phpx.x to install PHP by replacing xx with the latest available PHP version (e.g. php7.4).
This will use a third-party repository to install the latest PHP package, but you can download and install it manually from the PHP website You can run php-v again after installation to check if the installation was successful.
- The latest version of PHP will be installed, but you will need to change the version of PHP used by your web server. If you are using Apache, enter sudo a2enmod phpx.x (replacing xx with the correct version) to change the Apache server settings, then restart Apache by typing sudo systemctl restart apache2 or sudo service apache2 restart.
When installing without using Apache, refer to your web server software documentation to update the PHP version used to configure your server and install additional PHP modules (plugins) for your PHP version.
After updating PHP, your web server settings were changed to use the new version, and your web server was restarted, your WordPress site will start using it.
Keep your WordPress site secure
WordPress is at the core of millions of sites around the world, and like other web administrators, you need to keep your WordPress site secure. Now that you know how to update PHP in WordPress, you should do a full security audit – if your site has holes, you may have WordPress malware that you need to remove.
If you’re new to WordPress, here are some essential WordPress plugins for getting your website up and running quickly. Let us know your WordPress security tips in the comments section.
–