Гарантия возврата средств - 60 дней!
Обновление версии PHP на сервере
- 25.01.2023
- 0
- admin
In this article, we will explain how to update the PHP version on a virtual or dedicated server ( VPS, VDS, DS ) running the most popular operating system for web servers, OS CentOS.
Caveats. We want to warn you right away, many popular engines are demanding on PHP versions and a set of modules. Therefore, before updating PHP on the server, check the compatibility of your CMS with the new version of PHP. Usually this information can be found on the official websites of developers. Some modules may not be available on newer versions of PHP. For example, Zend Optimizer only works with php versions up to 5.2, on PHP 5.3 version, its analogue, Zend Guard Loader, is used. At the same time, if the script is encoded using Zend Optimizer, Zend Guard will not be able to process this script.
Installing an SSH client. You will need SSH access to the server and an SSH client. If you have a Linux operating system installed on your PC, you do not need an SSH client, you can use a standard Linux terminal to connect via SSH. For owners of Windows computers, we recommend using the Putty SSH\Telnet client. This program is free and easy to use. You can download the latest version from the official website at the link:
Connect to your server via SSH as root or another user with similar privileges. Checking current versions. First of all, let's check the current PHP version and the list of modules. To find out the PHP version, use the command:
php -v
To view the list of modules, use the following command:
php -m
PHP update. To update the PHP version, connect to the server via SSH and use the following command:
yum update php
You may be lucky and yum will immediately prompt you to upgrade to the PHP version you need, but this is unlikely. You will most likely get this response:
“No packages marked for update”
So you need to add a repository. A repository is a special remote repository from which a package will be installed. Let's look at the process of adding a repository and updating PHP in more detail. To update PHP, use the epel and remi repositories. These repositories are proven by years of faithful work for administrators of virtual and dedicated servers on Unix like systems. We do not recommend installing packages from third-party repositories. You can install the epel repository with the following command:
yum install epel-release
To add the remi repository on CentOS 6 use the following commands:
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
sudo rpm -Uvh remi-release-6*.rpm
To install the remi repository on CentOS 7, use the following commands:
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo rpm -Uvh remi-release-7*.rpm
Now you can update PHP. Update PHP to version 5.4 with the command:
yum update - -enablerepo=remi php
If you need to upgrade to version 5.5, use the command:
yum update --enablerepo=remi-php55 php
If you need to upgrade to version 5.6, use the command:
yum update --enablerepo=remi-php56 php
To upgrade to the new PHP 7 branch, use the following command:
yum update --enablerepo=remi-php70
After the update, be sure to restart the web server. To do this, use the command:
service httpd restart
If there is no httpd on your server - most likely the Nginx + PHP-FPM bundle is working, then reload PHP-FPM :
service php-fpm restart
Check the PHP version with the command:
php -v
We also recommend that you immediately install a package of popular PHP extensions. Use one of the following commands for this (depending on PHP version):
yum install --enablerepo=remi php-{mysql,mcrypt,mbstring,gd,xml}
yum update --enablerepo=remi-php55 php-{mysql,mcrypt,mbstring,gd,xml}
yum update --enablerepo=remi-php56 php-{mysql,mcrypt,mbstring,gd,xml}
yum update --enablerepo=remi-php70 php-{mysql,mcrypt,mbstring,gd,xml}
After installing the updates, restart the web server again. To do this, use the command:
service httpd restart
If there is no httpd on your server - most likely the Nginx + PHP-FPM bundle is working, then reload PHP-FPM :
service php-fpm restart
Upgrading PHP to 7.2 on CentOS 7
To update PHP to version 7.2, you need to run the following commands:
rpm -ivh http://rpms.remirepo.net/enterprise/remi-release-7.rpmyum -y install epel-release yum-utilsyum remove php*yum-config-manager –enable remi-php72yum install php php-xml php -soap php-xmlrpc php-mbstring php-json php-gd php-mcrypt php-common php-fpm php-pdo php-mysqlnd php-imap php-embedded php-ldap php-odbc php-zip php-fileinfo php-process php-opcachesystemctl restart httpd
If you have any problems, open a ticket from your personal account, and our specialists will definitely help you.
WELL-WEB 2023