How to execute PHP7 CLI commands with cPanel and EasyApache 4 – PHP7 CLI path

How to execute PHP7 CLI commands with cPanel and EasyApache 4 - PHP7 CLI path

Today I had an hard time helping a friend installing a Laravel PHP application on a WHM-powered OVH Server: since he needed PHP7, the first thing I did was upgrading EasyApache to version 4, which has built-in PHP7 support. Once I did that, enabling PHP7 as a dynamic Apache module was just as easy as adding the following lines to the .htaccess file in the root apache folder:

It’s worth noting that these commands are automatically added by EasyApache 4 if you choose a PHP7-enabled template among those already shipped with the product.

Right after that, PHP7 worked right off the bat: too bad he also had to run composer/artisan scripts to actually deploy his Laravel-based application, which he hoped he could do via SSH/SCP using the PHP Command-Line Interface. However, as soon as he tried to run the required commands, he was struck by the fact that the available PHP CLI was 5.4, as it was still the default PHP version referenced by the $PATH environment variable.

In order to fix that, we had to discover where the real path to PHP7 CLI actually was.

Luckily enough, we quickly found the answer that we need by looking at the cPanel support forum:

By knowing that, he was able to run using the following command:

And run the Composer scripts required by Laravel to create the DB and perform the deploy.

 

RELATED POSTS

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies.

View all posts by Ryan