How to change PHP version on Business servers

ByJUJU-dev

How to change PHP version on Business servers

Changing the PHP version on a business server can be a bit more complex than on a shared hosting environment, as it requires manually editing configuration files and restarting services. Here’s a step-by-step guide on how to change the PHP version on a business server:

Step 1: Identify the current PHP version

  • Log in to your business server using SSH or your preferred method.
  • Check the current PHP version by running the command php -v or php --version.
  • Note down the current PHP version, as you’ll need it later.

Step 2: Update the package manager

  • If you’re using an RPM-based distribution like CentOS or RHEL, update the package manager (Yum) by running the command sudo yum update.
  • If you’re using a DEB-based distribution like Ubuntu or Debian, update the package manager (Apt) by running the command sudo apt-get update.

Step 3: Install the new PHP version

  • Use your package manager to install the desired PHP version. For example:
    • RPM-based distributions: sudo yum install php71w-fpm (for PHP 7.1) or sudo yum install php73-fpm (for PHP 7.3).
    • DEB-based distributions: sudo apt-get install php7.1-fpm (for PHP 7.1) or sudo apt-get install php7.3-fpm (for PHP 7.3).

Step 4: Enable the new PHP version

  • Create a symbolic link to the new PHP version:
    • RPM-based distributions: sudo ln -s /opt/rh/php71/root/usr/bin/php /usr/bin/php71 (for PHP 7.1) or sudo ln -s /opt/rh/php73/root/usr/bin/php /usr/bin/php73 (for PHP 7.3).
    • DEB-based distributions: sudo update-alternatives --install /usr/bin/php php /usr/lib/php/7.1/bin/php 1 (for PHP 7.1) or sudo update-alternatives --install /usr/bin/php php /usr/lib/php/7.3/bin/php 1 (for PHP 7.3).

Step 5: Set the default PHP version

  • Update the default PHP version by running:
    • RPM-based distributions: sudo alternatives --set php /usr/bin/php71 (for PHP 7.1) or sudo alternatives --set php /usr/bin/php73 (for PHP 7.3).
    • DEB-based distributions: sudo update-alternatives --set php /usr/lib/php/7.1/bin/php (for PHP 7.1) or sudo update-alternatives --set php /usr/lib/php/7.3/bin/php (for PHP 7.3).

Step 6: Restart services

  • Restart the Apache or Nginx service to apply the changes:
    • RPM-based distributions: sudo systemctl restart httpd
    • DEB-based distributions: sudo service apache2 restart

Step 7: Verify the new PHP version

  • Run the command php -v or php --version again to verify that the new PHP version is active.

That’s it! You’ve successfully changed the PHP version on your business server.

Remember to test your website and applications after changing the PHP version to ensure everything is working as expected.

About the author

JUJU-dev administrator

Leave a Reply

3 × 5 =