Show
I’ll show you how to upgrade PHP 5.6.xx which is by default installed by Vesta CP during installation to PHP 7.2.xx latest, I’ve tested on many server before writing this tutorial and its just working fine without any issue hence it is safe to upgrade to PHP 7.2, part of this tutorial is copied from remi repository. Why upgrade to php 7.2 – Because it will give you security & performance boost + KICK, since WordPress will load much faster and uses less resources. STEP 1 : Install Remi Repository and EPEL Repository on your server : wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm RHEL 6 wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm CentOS 7 wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm CentOS 6 wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm STEP 2 : After you have installed
repository you need to follow some extra configurations : yum install yum-utils STEP 3 : Now just run this command : yum update -y You’ll see php packages are getting updated, After the update process you need to restart Apache server/php-fpm-(nginx) and check the php version from by below mentioned command: php -v [root@server ~]# php -v I have seen several different versions of this process, but none of them worked… Here is the summary, but make sure you keep track of all changes in case you need to revert. Note: If you are using CentOS Web Panel, the update can be done from the dashboard. At the bottom of the dashboard, click on the tiny Edit sign next to the PHP Switcher. Select the desired PHP version and the extensions needed.Then click on the Save & Build button. The PHP Compiler has been started in the background. The process can take up to 30 minutes and you will see high CPU usage while this happens. You can follow the process in /var/log/php-rebuild.log When the update is completed, you will be able to see the new PHP version: You can also check the version in Putty:
You can see the new version, but also that Ioncube loader isn’t working. Warning: Even though we are already at 7.4.7, there are still missing extensions that may break your site. Therefore make sure you don’t delete PHP 7.3 and proceed with caution, because you can break WordPress plugins. This is the reason why even hosts like SiteGround still have 7.3 listed as their managed PHP version. Manual UpdateVersion #11. Verify current version of PHPType in the following to see the current PHP version:
The output should be something like this:
2. Install the REMI and EPEL repositoriesIf you don’t already have them, install the Remi and EPEL repositories:
Enable the Remi repository globally:
Under the section that looks like [remi] make the following changes (enabled=0):
Enable the Remi PHP7.4 Repository:
Under the section that looks like [remi-php74] make the following changes (enabled=1):
3. Install required extensionsYou can list the existing extensions using command below :
Simply prefix To view enabled modules, run:
You can run the following command to search other available PHP modules under configured yum repositories. Below example command search for all modules for PHP 7.3. yum --enablerepo=remi-php73 search php | grep php73
4. Upgrade PHP 5.4 to PHP 7.4Now we can upgrade PHP. Just type in the following command:
This above procedure installed the updated PHP, however it isn’t active. Version #2Here is another version. Most steps are similar, but there are additional ones: 1. Download Remi and EPEL Repository packagesFirst, download Remi and EPEL Repository packages: $ wget -q http://rpms.remirepo.net/enterprise/remi-release-7.rpm $ wget -q https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 2. Enable Remi and EPEL RepositoryInstall both previously downloaded packages and enable Remi PHP 7 repo: # rpm -i remi-release-7.rpm epel-release-latest-7.noarch.rpm FOR PHP 7.0 EXECUTE: # yum-config-manager --enable remi-php70 FOR PHP 7.1 EXECUTE: # yum-config-manager --enable remi-php71 FOR PHP 7.2 EXECUTE: # yum-config-manager --enable remi-php72 FOR PHP 7.3 EXECUTE: # yum-config-manager --enable remi-php73 FOR PHP 7.4 EXECUTE: # yum-config-manager --enable remi-php74 Current latest PHP version from Remi repository is 7.4. Amend the above command for any other subsequent PHP releases. ??? This may be an alternative comman:
These are the missing steps cut from another tutorial:Step 5 – Now delete current PHP installation but make sure you stopped Apache first:
Step 6 – Finally, issue this command to install PHP 7.4 with all necessary modules: yum –enablerepo=remi-php74 install php74-php php74-php-pear php74-php-bcmath php74-php-pecl-jsond-devel php74-php-mysqlnd php74-php-gd php74-php-common php74-php-fpm php74-php-intl php74-php-cli php74-php php74-php-xml php74-php-opcache php74-php-pecl-apcu php74-php-pecl-jsond php74-php-pdo php74-php-gmp php74-php-process php74-php-pecl-imagick php74-php-devel php74-php-mbstring Step 7 – Next, at this point, you can simply stop the old PHP-fpm service and start the newly installed PHP74-fpm (Obviously you should use the alternative if you have php-cgi)
Step 8 – Finally you can delete the old php symblink and create a new one:
Also do not forget to restart Apache service / httpd:
These may or may not be relevant: If you are using Apache as your web server then just restart the Apache service using the following command and you are good to go:
Unlike Apache, Nginx doesn’t have built-in support for processing PHP files so we need to install a separate application such as PHP FPM which will handle the PHP file To install the PHP FPM package run the following command:
By default PHP FPM will run as user /etc/php-fpm.d/www.conf
Make sure the
Once you made the changes, enable and start the PHP FPM service:
Next, edit the Nginx virtual host directive and add the following location block so that Nginx can process PHP files:
For the new configuration to take effect, restart the Nginx service:
How upgrade PHP 5.4 to PHP 7.4 on CentOS 7?Update PHP 5.4 version to PHP 7.4. Check the version of the php. # php - v.. Current version is PHP 5.4 . Install Remi Repository and EPEL Repository by using following commands . ... . PHP has been updated to 7.4. Thank you!!. How do I upgrade PHP 5.6 to 7?Code to Upgrade from PHP5 to PHP7
Set error reporting to E_ALL as below. Eg: error_reporting(E_ALL ^ E_STRICT); Solve all the errors including notice errors and deprecated errors. Create an abstraction layer for database operations by using PDO extension as PDO supports multiple databases.
How upgrade PHP 5.4 to PHP 5.6 on CentOS 7?upgrading php 5.4 to 5.6 on CentOS 7. After installing Webtatic yum repository, you need to remove the old version of php-common package. ... . Now we install PHP 5.6 using following command: # yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring.. How do I upgrade PHP to 7?Upgrading or Downgrading PHP Versions. Ensure the php packages for the version you want are installed.. Update any configuration for that PHP version.. Update your web server configuration to point to the correct PHP version.. Point PHP CLI to the correct PHP version.. Restart your web server and php-fpm.. |