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 /public_html/  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 php artisan  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 php artisan  using the following command:

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

 

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. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

One Comment on “How to execute PHP7 CLI commands with cPanel and EasyApache 4 - PHP7 CLI path”

  1. that was a great help. but can you please give an example on composer command as well. i am not being able to run it successfully.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.