How to upgrade the PHP version of the website on a Linux server? CWP7PHP Version Switcher

the websiteLinuxThe server is upgraded to a higher version of the PHP environment, and the web page opening speed will be 3 to 5 times faster than the previous PHP version, and the security of the website is also improved.

But before upgrading the PHP version, it is very important to know whether the website is fully compatible with the PHP environment to be upgraded, because if the webpage cannot be opened or the page cannot be fully loaded, it will be troublesome.

How to upgrade the PHP version of the website on a Linux server?

Here is an introduction to the Linux server CentOS7.3 The specific method for upgrading from PHP5.6.40 to PHP7.4.28.

Step 1:View the PHP version installed on the current Linux server▼

php -v

Step 2:close php-fpm ▼

service php-fpm stop

Step 3:uninstall php ▼

yum remove php-common

Step 4:Install source epel ▼

yum install epel-release

Step 5:Install source remi ▼

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm

Step 6:Install yum-config-manager ▼

yum -y install yum-utils

Step 7:Use yum-config-manager to specify remi's php7.4 repository▼

yum-config-manager –enable remi-php74

Step 8:Install and upgrade php ▼

yum update php php-opcache php-xml php-mcrypt php-gd php-devel php-mysql php-intl php-mbstring php-common php-cli php-gd php-curl -y

Step 9:View current PHP version ▼

php -v
  • 注意:如果要安装其他版本,可以在第7步将remi-php74改为remi-php72、remi-php71、remi-php70等等……

How to upgrade CWP7 to change the PHP version?

ifInstall CWP Control PanelIf so, please ignore the above steps and just follow the tutorial below to change the PHP version.

Now CWP 7 has a PHP Switch option where you can switch to a different PHP version very easily and recompile it with the required modules.

OnCWP Control PanelClick on the left → PHP Settings → PHP Version Switcher: Manually select the PHP 7.4.28 version ▼

How to upgrade the PHP version of the website on a Linux server? CWP7PHP Version Switcher

  1. Click on the PHP version switcher (here you will get the server PHP version and the compiled modules your server is now compiled with).
  2. Select the PHP version you want to compile from the drop-down menu, then click Next.
  3. In the PHP compiler, you can add or remove modules as you want.
  4. Click Start Compiler and the compiler will start working in the background.
  • The compiler takes 5 to 20 minutes to complete, depending on the modules you have installed and the CPU power.
  • You can check back in 15 minutes and check what version of PHP and modules you have now in CWP – PHP Version Switch.
  • Your website and CWP will work as usual during compilation, and the PHP version will be updated after compilation is complete.

You can check the PHP compilation log in the file:

/var/log/php-rebuild.log

If you want to monitor the compiler, use this command in the shell:

tail -f /var/log/php-rebuild.log

How to upgrade and change PHP version in CWPYouTubeVideo tutorial

Here's a YouTube video tutorial on how to upgrade your website's PHP version from the CWP control panel:

How to add custom build flags to PHP switcher?

This can be done by editing the configuration file located at:

CentOS 7: /usr/local/cwpsrv/htdocs/resources/conf/el7/php_switcher/

CentOS 8: /usr/local/cwpsrv/htdocs/resources/conf /el8/php_switcher/

Example:

/usr/local/cwpsrv/htdocs/resources/conf/el7/php_switcher/7.0.ini

At the end of this file, we add:

[shmop-test]
default=0
option="--enable-shmop"
  • in square brackets[shmop-test], you create the name that will be used for the build, which must be unique and not previously defined in the file.
  • Under options, you need to define build flags.
  • After editing, you can build new PHP from the CWP PHP version switcher.
  • Note that CWP updates will overwrite this file!

Hope Chen Weiliang Blog ( https://www.chenweiliang.com/ ) shared "How to upgrade the PHP version of the website on a Linux server? CWP7PHP Version Switcher" to help you.

Welcome to share the link of this article:https://www.chenweiliang.com/cwl-27807.html

Welcome to the Telegram channel of Chen Weiliang's blog to get the latest updates!

🔔 Be the first to get the valuable "ChatGPT Content Marketing AI Tool Usage Guide" in the channel top directory! 🌟
📚 This guide contains huge value, 🌟This is a rare opportunity, don’t miss it! ⏰⌛💨
Share and like if you like!
Your sharing and likes are our continuous motivation!

 

Comment

Your email address will not be published. Required fields * Callout

scroll to top