How to change the PHP version

How to change the PHP version

How to change the PHP version
How to change the PHP version

Changing the PHP version on your server can be necessary for compatibility with different applications or to take advantage of new features and performance improvements.

The steps to change the PHP version depend on the web server and control panel you are using.

How to change the PHP version – Here, we’ll cover the process for some common environments: cPanel, Plesk, and command-line on a Linux server.

How to change the PHP version
How to change the PHP version

Changing PHP Version in cPanel

  1. Log into cPanel:
  2. Find the PHP Selector:
    • In the Software section, click on Select PHP Version or MultiPHP Manager, depending on your hosting provider’s configuration.
  3. Select PHP Version:
    • If using Select PHP Version:
      • Choose the domain for which you want to change the PHP version.
      • Select the desired PHP version from the dropdown menu.
      • Click Set as current to apply the changes.
    • If using MultiPHP Manager:
      • Check the box next to the domain(s) you want to change.
      • Select the desired PHP version from the dropdown at the top of the page.
      • Click Apply to save the changes.

        How to change the PHP version
        How to change the PHP version

Changing PHP Version in Plesk

  1. Log into Plesk:
    • Access your Plesk control panel through your hosting provider’s login page.
  2. Go to Hosting Settings:
    • In the Websites & Domains section, find the domain you want to change the PHP version for.
    • Click on Hosting Settings.
  3. Select PHP Version:
    • Find the PHP support section.
    • Use the PHP version dropdown to select the desired version.
    • Click OK or Apply to save the changes.

Changing PHP Version via Command-Line on a Linux Server

  1. Check Current PHP Version:
    • Open a terminal or SSH into your server.
    • Run the command:

      bash

      php -v
    • This will display the currently active PHP version.
  2. Install New PHP Version (if not already installed):
    • For Ubuntu:

      bash

      sudo apt update
      sudo apt install php7.x
    • For CentOS:

      bash

      sudo yum install epel-release
      sudo yum install php7.x
    • Replace 7.x with the desired PHP version number (e.g., 7.4, 8.0).
  3. Update Alternatives:
    • On Ubuntu:

      bash

      sudo update-alternatives --set php /usr/bin/php7.x
    • On CentOS, you may need to update the symlinks manually:

      bash

      sudo ln -sf /usr/bin/php7.x /usr/bin/php
  4. Restart Web Server:
    • For Apache:

      bash

      sudo systemctl restart apache2 # On Ubuntu/Debian
      sudo systemctl restart httpd # On CentOS/RHEL
    • For Nginx (you might need to configure PHP-FPM):

      bash

      sudo systemctl restart php7.x-fpm
      sudo systemctl restart nginx
  5. Verify PHP Version:
    • Run the command again to confirm the change:

      bash

      php -v

Post-Change Verification

After changing the PHP version, it’s important to verify that your applications are working correctly. Check the following:

  • Website Functionality: Visit your website and ensure all features are functioning as expected.
  • Error Logs: Check the server error logs for any PHP-related errors.
  • Compatibility: Make sure your applications and plugins are compatible with the new PHP version.

By following these steps, you can change the PHP version on your server using different control panels or the command-line interface, ensuring your web environment meets the required specifications for your applications.

About

View all posts by