Christian Mayer's Weblog

OVH PHP Command Line Interface (CLI)

Sometimes when you work with PHP frameworks like Laravel or Symfony you need to go to the command line and execute some initial commands for the installation or maybe maintenance.

If you manage your own root server by yourself this isn’t a problem in most cases. But when you are on a shared hosting server your access is restricted. This means you maybe also have a shell to your server but only with a few commands available.

On a OVH shared hosting server you get a very old version of PHP:

:ovh> php --version
PHP 4.4.9 (cgi) (built: Apr 20 2012 18:34:17)

Consider the first digit: 4. This is not even PHP 5.0. Don’t get confused with numbers: 4.4 != 5.4.

The which command brings more information:

:ovh> which -a php
/usr/local/bin/php

Well, not really. But ls -la always helps:

:ovh> ls -la /usr/local/bin/php*
ls: cannot access /usr/local/bin/php*: No such file or directory

This is because we are on a very restricted server.

Doing it manually:

:ovh> ls -la /usr/local/bin/php 
lrwxrwxrwx 1 root staff 10 Apr 16 22:42 /usr/local/bin/php -> php.ORIG.4
:ovh> ls -la /usr/local/bin/php.ORIG.4
lrwxrwxrwx 1 root staff 14 Apr 24  2012 /usr/local/bin/php.ORIG.4 -> php.ORIG.4.4.9
:ovh> ls -la /usr/local/bin/php.ORIG.4.4.9
-rwxr-xr-x+ 1 root root 3551656 Apr 23  2012 /usr/local/bin/php.ORIG.4.4.9

So trying it with a 5 instead of 4 brings us the following result:

:ovh> ls -la /usr/local/bin/php.ORIG.5
lrwxrwxrwx 1 root staff 12 Jul 20  2012 /usr/local/bin/php.ORIG.5 -> php.ORIG.5_2
:ovh> ls -la /usr/local/bin/php.ORIG.5_2
lrwxrwxrwx 1 root staff 15 Jul 20  2012 /usr/local/bin/php.ORIG.5_2 -> php.ORIG.5.2.17
:ovh> ls -la /usr/local/bin/php.ORIG.5.2.17
-rwxr-xr-x+ 1 root root 9818620 Jun  7  2012 /usr/local/bin/php.ORIG.5.2.17

On a forum page[1] they also wrote that php.TEST.5 is available:

:ovh> ll /usr/local/bin/php.TEST.5
lrwxrwxrwx 1 root staff 29 Feb  5 16:51 /usr/local/bin/php.TEST.5 -> /usr/local/php5.3/bin/php-cgi

This brought me to /usr/local/php*/bin/php-cgi:

:ovh> ll /usr/local/php5.3/bin/php-cgi
-rwxr-xr-x 1 root root 10586236 Dec 10 18:04 /usr/local/php5.3/bin/php-cgi
:ovh> ll /usr/local/php5.4/bin/php-cgi
-rwxr-xr-x 1 root root 10177332 Feb  9 18:25 /usr/local/php5.4/bin/php-cgi
:ovh> ll /usr/local/php5.5/bin/php-cgi
-rwxr-xr-x 1 root root 10642868 Feb  9 18:26 /usr/local/php5.5/bin/php-cgi
:ovh> ll /usr/local/php5.6/bin/php-cgi
-rwxr-xr-x 1 root root 10874260 Feb  9 18:25 /usr/local/php5.6/bin/php-cgi

For PHP used by the HTTP process you can create a file named .ovhconfig in your root directory with the following content:

app.engine.version=5.6

The following versions are available:

In their help OVH wrote that 5.4 is the default but it’s acctually 5.3.

Conclusion

Here are all paths for the shell listed again:

/usr/local/bin/php.ORIG.4
/usr/local/bin/php.ORIG.5
/usr/local/php5.3/bin/php-cgi
/usr/local/php5.4/bin/php-cgi
/usr/local/php5.5/bin/php-cgi
/usr/local/php5.6/bin/php-cgi

Footnotes

Posted on .
Categories: Productivity
Tags: PHP, CLI, Command, Line, Interface, Shell, Terminal, Bash, Shared, Hosting, Laravel, Symfony, maintenance, custom, version, server

Imprint | Usage | Categories | RSS Feed
Copyright © 2006 by