
PHP update in WordPress - how to do it safely and effectively?
Are you wondering how to safely and effectively update PHP on your WordPress site? In this article, we will take you step-by-step through the process of preparing your environment, choosing the right PHP version, upgrading on your hosting server, and testing the compatibility of themes and plugins. In addition, we will discuss the most common problems you may encounter, and present methods to optimize performance after the upgrade. With our tips, updating PHP in Wordpress will be fast, safe and without potential complications.

- 1. How to update PHP on a hosting server?
- 1.1. Steps to follow:
- 2. PHP update via console (SSH)
- 3. PHP update – instructions for different systems:
- 3.1. Debian/Ubuntu:
- 3.2. RedHat / CentOS / AlmaLinux / Rocky Linux
- 4. Update PHP via FTP and wp-config.php
- 4.1. How to update WordPress files via FTP?
- 4.2. How to force PHP version on some hosts?
- 4.3. Is it possible to force PHP version in wp-config.php?
- 5. Preparing the environment for a PHP upgrade on WordPress
- 6. Testing theme and plugin compatibility after a PHP update
- 7. FAQ – frequently asked questions
- 7.1. Why update PHP?
- 7.2. How to check the PHP version in WordPress?
- 7.3. Will updating PHP affect the performance of my site?
- 7.4. What if my site stops working after the update?
How to update PHP on a hosting server?
Updating PHP wordpress on your hosting server may seem complicated, but with the right approach the process becomes simpler.
Steps to follow:
- Log into the hosting management panel (e.g. cPanel, Plesk).
- Go to the PHP section and select the option to change the PHP version.
- Select the latest stable version of PHP and confirm the changes.
- Restart the server, if required.
- Test your site, to make sure it works properly after the update.
PHP update via console (SSH)
If you have access to the server via SSH (for example, on a VPS or dedicated server), you can manually update PHP. This method is recommended for advanced users who manage their own server.
Checking the current PHP version. First, check what version of PHP is currently installed:
php -v
PHP update – instructions for different systems:
Debian/Ubuntu:
1. Update the package list:
sudo apt update && sudo apt upgrade -y
2. Add a repository with current PHP versions:2. add a repository with current PHP versions:
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
3. Uninstall the old version of PHP (optional, but recommended):3. uninstall the old version of PHP (optional, but recommended):
sudo apt remove php*
4. Zainstaluj najnowszą wersję PHP (np. PHP 8.2):
sudo apt install php8.2 php8.2-cli php8.2-fpm php8.2-mysql php8.2-curl php8.2-gd php8.2-mbstring php8.2-xml php8.2-zip -y
5. Check if the new version is active:
php -v
6. Reboot the server for the changes to take effect:6. reboot the server for the changes to take effect:
sudo systemctl restart apache2 # If use Apache
sudo systemctl restart nginx # If use Nginx
RedHat / CentOS / AlmaLinux / Rocky Linux
1. Install the Remi repository (if you don’t already have it):
sudo yum install -y epel-release yum-utils
sudo yum-config-manager --enable remi-php82
2. Uninstall the old version of PHP (optional):
sudo yum remove php*
3 Install the latest version of PHP:
sudo yum install -y php php-cli php-fpm php-mysqlnd php-curl php-gd php-mbstring php-xml php-zip
4. Check the PHP version:
php -v
5. Restart the server:
sudo systemctl restart httpd # If use Apache
sudo systemctl restart php-fpm # If use PHP-FPM
Additional steps after the upgrade: Check that the new PHP version is working in WordPress: In the admin panel, go to Tools → Site Info → Server. Update PHP configuration files(php.ini
), if you have custom settings. If the site stops working, check the PHP error logs.
Update PHP via FTP and wp-config.php
Directly updating PHP via FTP is not possible, because FTP is only for file transfer and does not allow you to change server settings. However, if you want to update WordPress files, you can do it manually via FTP:
How to update WordPress files via FTP?
- Download the latest version of WordPress from the official site.
- Unzip the downloaded archive on your computer.
- Connect to the server using an FTP client (such as FileZilla).
- Navigate to the directory where you installed WordPress.
- Copy all the files from the unzipped archive (excluding the
wp-content
folder ) to the server, overwriting the existing files. - Once the copying is complete, log into the WordPress admin panel and follow the update instructions.
How to force PHP version on some hosts?
Although you can’t update PHP via FTP, on some hosts you can force a specific PHP version via .htaccess
or .user.ini
file .
Change the PHP version in .htaccess
(if your hosting allows it):
Add the following code to the beginning of the .htaccess
file :
AddHandler application/x-httpd-php82 .php
(Change 82
to the appropriate PHP version, such as 74
for PHP 7.4).
Change the PHP settings in .user.ini
(if supported by the hosting):
Create or edit the .user.ini
file in the WordPress root directory and add:
php_version 8.2
Is it possible to force PHP version in wp-config.php
?
No, the wp-config.php
file does not allow you to change the PHP version. However, you can activate PHP debug mode to detect errors after PHP updates:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('log_errors', 1);
@ini_set('error_log', dirname(__FILE__) . '/wp-errors.log');
After updating PHP, it’s a good idea to monitor the wp-errors.log
file to make sure all plugins and themes are working properly.
Preparing the environment for a PHP upgrade on WordPress
Before you start updating the PHP on your WordPress site, it is crucial to ensure the security and stability of your site. The first step is to take a full backup, to avoid data loss in case of unforeseen problems. Use tried-and-true backup plugins or take advantage of the tools offered by your hosting provider.
The next step is to check the compatibility of themes and plugins with the new PHP version. Perform the following steps:
- Review the documentation of all plugins and themes you use for PHP requirements.
- Contact the plugin developers if you are unsure of compatibility.
- Conduct tests on your staging environment to ensure that the functionality of your site will not be negatively affected by the upgrade.
Also, don’t forget to update WordPress itself to the latest version, which can increase compatibility with the new PHP. Regularly monitoring your site’s performance after the update will help you quickly identify and resolve any issues, ensuring your site runs smoothly.
Testing theme and plugin compatibility after a PHP update
After a PHP update, it’s crucial to check that all themes and plugins work flawlessly. You can do this by:
- Testowanie w środowisku stagingowym – przed wprowadzeniem zmian na stronie produkcyjnej.
- Korzystanie z wtyczek do testowania kompatybilności – np. „PHP Compatibility Checker”.
- Monitorowanie logów błędów – jeśli zauważysz problemy, sprawdź logi serwera.
FAQ – frequently asked questions
Why update PHP?
Newer PHP versions improve performance, security and compatibility with new WordPress features.
How to check the PHP version in WordPress?
Go to Tools > Site Info > Server, where you can find information about the current PHP version. You can also use the “Display PHP Version” plugin.
Will updating PHP affect the performance of my site?
Yes, it may affect the compatibility of plugins and themes. It is recommended to check the documentation and test on a staging environment.
What if my site stops working after the update?
If your site stops working after a PHP update, follow the steps below:
Sometimes errors after a PHP update can be caused by incompatible plugins or themes. Enable debug mode to see more details:
- Connect to the server via FTP or hosting panel.
- Open the file
wp-config.php
. - Add or edit the following lines:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
@ini_set('log_errors', 1);
@ini_set('error_log', dirname(__FILE__) . '/wp-errors.log');
4 Check the wp-errors.log
file in the WordPress root directory – you will find error details there.


