How to change default PHP version in plesk

How to change default PHP version in plesk

In this article, I am referring to change default php version in plesk. In latest plesk versions are come with all the php versions installed ( we have the option to install all the php versions ). So no need to install a separate php in the server for setting the default PHP to the latest version. Creating symlink and some additional commands to bring the default handler to the required version.

Here is the environment in which the command worked.

Plesk Version : 17.5.3 CentOS 7

List the php handlers

/usr/local/psa/admin/bin/php_handlers_control --list

Verify the default php version.

php -v

Check the PHP version 5.6

/opt/plesk/php/5.6/bin/php -v

Find the default php binary

which php

Backup the php, php-cgi and php-fpm binaries.

mv /usr/bin/php /usr/bin/php.backup
mv /usr/bin/php-cgi /usr/bin/php-cgi.backup
mv /sbin/php-fpm /sbin/php-fpm.backup

Create symlink from php 5.6 binaries

ln -s /opt/plesk/php/5.6/bin/php /usr/bin/php
ln -s /opt/plesk/php/5.6/bin/php-cgi /usr/bin/php-cgi
ln -s /opt/plesk/php/5.6/sbin/php-fpm /sbin/php-fpm

You can set symlink from any other php version installed in the server. Following are the php bnaries for other versions, find the same for php-cgi and php-fpm too.

/opt/plesk/php/5.3/bin/php 
/opt/plesk/php/5.4/bin/php 
/opt/plesk/php/5.5/bin/php
/opt/plesk/php/5.6/bin/php
/opt/plesk/php/7.0/bin/php 
/opt/plesk/php/7.1/bin/php
/opt/plesk/php/7.2/bin/php

Once the symlink is created, the php version will show the new version we set. You can check it using the following command.

php -v

Next option is to update the plesk database with the changed versions. The reread option will update plesk database with the new versions.

/usr/local/psa/admin/bin/php_handlers_control --reread

After that reconfigure all the domains or the domains using the default php versions. And proceed with a service restart.

/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
service httpd restart

Once this is completed, the sites will load with new php version.

Note: Make sure to do this by a qualified technician.

If you need us to do these changes for your server, please get it touch without support

Facebook Comments