SEO, Website Development and Online Marketing for Trades People

Change PHP Version in Plesk using command line

Change PHP Version in Plesk using command line

Thu, 13/02/2020 - 07:57
0 comments
Change PHP Version in Plesk using command line

As a Drupal developer, I use composer which is a dependency manager for PHP.  A big part of developing Drupal 8 and above is to be able to use composer to install Drupal core, modules, themes and all dependencies without having to manually install everything individually. It is now recommended to install a Drupal module using composer to download it's dependencies. 

I run a few dedicated servers which run the latest versions of Plesk. Plesk is an amazing piece of software that allows to build, secure and run websites and applications in the Cloud through a simple web based interface. 

When connecting to Plesk with SSH (command line) it is sometimes necessary to change the PHP version. To do this, you can use the following:

This changes the php version to PHP7.2

/opt/plesk/php/7.2/bin/php /usr/lib64/plesk-9.0/composer.phar

This changes the php version to PHP7.3

/opt/plesk/php/7.3/bin/php /usr/lib64/plesk-9.0/composer.phar

This changes the php version to PHP7.4

/opt/plesk/php/7.4/bin/php /usr/lib64/plesk-9.0/composer.phar

An example of installing the Drupal Address module with a minimum dependency of PHP7.3

/opt/plesk/php/7.3/bin/php /usr/lib64/plesk-9.0/composer.phar require drupal/address