DEV Community

loading...
Cover image for Use PHP CLI 7.3 on OVHcloud Performance hosting

Use PHP CLI 7.3 on OVHcloud Performance hosting

capripot profile image Ronan ・2 min read

OVHcloud is the 3rd website hosting company worldwide, 1st in Europe. They have a good product called Performance Hosting which includes a direct SSH access to the shared server.

My goal was to use Ruckus Migrations on production the same way I do in my local development. Ruckus is a database migrations manager, it is inspired by the Rake database migration tools available with Ruby-on-Rails framework.

In today's version of the hosting, we can use PHP 7.3

/usr/local/php7.3/bin/php -v
# PHP 7.3.18 (cli) (built: May 20 2020 12:29:48) ( NTS )

Alias it to php7 and source .bashrc so our current terminal re-loads commands present in it.

echo "alias php7='/usr/local/php7.3/bin/php" >> .bashrc
source .bashrc

And we are good to go

php7 ruckus.php db:migrate ENV=production

My original solution

To use it, we need PHP 5.3 minimum. The default php command line on Performance Hosting was PHP 4. But actually, other versions of PHP are available. PHP 5.4.45 cli binary is available under the sweet name of php.ORIG.5_4.

If we try to use it directly, it will complain because it tries to use the php.ini configuration file used for PHP 4, so we should provide the 5.4 ini file. We can find it through the phpinfo() function.

So, after getting to know all these information, we are able to use PHP cli 5.4:

php.ORIG.5_4 -c /usr/local/lib/php.ini-2

But since we probably don’t want to memorize all of that to use PHP cli each time we need it, we should export it as an alias in our .bashrc file.

echo "alias php5='php.ORIG.5_4 -c /usr/local/lib/php.ini-2'" >> .bashrc

After re-sourcing our bash file

. .bashrc

We can now execute our scripts with PHP cli 5.4

php5 ruckus.php db:migrate ENV=production

Originally published on September 23, 2014
Photo by OVHcloud

Discussion (0)

pic
Editor guide