This guide will help you to configure PHP on your OVH web server.

PLEASE NOTE: The .ovhconfig file comes automatically with the Web Hosting 2014 plan, however, it is not automatically added to earlier offers or when you change your plan, as certain settings may not be compatible with your version of PHP. For these plans, you will need to create the file and save it to the root of your disk space.

The .ovhconfig file can only be saved at the root of your disk space or in a top-level directory. You can't use several files to bring together different PHP configurations on one web server, apart from correctly used multi-domaines.

How do you adjust your PHP preferences?

.

How do you migrate to another version of PHP?

You need to have the .ovhconfig file in place in root of your disk space, via FTP.

To use PHP 5.5 for example, the .ovhconfig file will contain the following code:

app.engine=php
app.engine.version=5.5
http.firewall=none
environment=production
.

Which version(s) of PHP are available?

You can use the following versions of PHP:

  • 5.6 (ionCube not currently available)
  • 5.5
  • 5.4 (automatic version)
  • 5.3 (soon to be obsolete: not recommended)

PLEASE NOTE: the software publisher has discontinued earlier versions and we will gradually stop providing them. We will continue to carry out updates on new PHP versions when released, yet will cease to do this on older versions once they are no longer supported. We therefore advise that you ensure your pages are regularly updated.
You can follow the plans for and progress on these operations via OVH status: [url="https://status.ovh.net/"/url]

Please note that once .ovhconfig is in place, the version of PHP to be used is defined by app.engine.version. Variables in your .htaccess, such as SetEnv PHP_VER, will therefore be ignored.
.

You created your .ovhconfig and you get a "Not Implemented" error.

This means that the motor or the version specified in your .ovhconfig doesn't exist. Don't hesitate to look at your sites "error.log" for more information on the error.
.

What does the environment variable mean?

It allows you to specify the cache for static files as well as the behaviour of PHP errors.

In development mode:
  • no cache is stored
  • PHP logs are displayed on your site (display_errors=On)

In production mode: (default option)
  • static files such as images, videos, audio files have a longer lifespan which maximises file caching on web browsers
  • PHP logs aren't displayed on your site
.

What does the http.firewall variable mean?

This variable allows you to enable a type mod_security firewall application. To do this, add security.
http.firewall is set to none by default.
.

Details on the .ovhconfig file

Here is the information you need to deploy the .ovhconfig file:

; ovhconfig
;
; this file must be placed in $HOME/.ovhconfig or in $DOCUMENT_ROOT/.ovhconfig

; __app.engine__
;
; values: php (php engine + opcache accelerator)
; please note: if php, a phpcgi engine is activated as fallback (if previous engine crashed)
;
; php:
; IMPORTANT: register_globals and magic_quotes_gpc are not enabled for security reasons
; php options .htaccess (like php version) are ignored
; phpcgi:
; IMPORTANT this is a fallback or previous system
; in this case __app.engine.version__ will be considered as AUTO and PHP version will be an old version
; (depending on whether .htaccess or .phpX extension)
;
app.engine=php

; __app.engine.version__ specify version of your engine
;
; for php:
; default: 5.4
; for phpcgi:
; this options is ignored (= fallback in AUTO)
;
app.engine.version=5.4

; __http.firewall__ used to add application firewall (filter http requests)
;
; values: none | security
; default: none
;
http.firewall=none

; __environment__
;
; values: production | development
;
; production:
; apache will maximise local cache
; mod_expires will increase TTL of js, css, pdf, images, video, audio
; you can override it by changing expiration in your .htaccess
; feel free to follow our guide.
; development:
; no expiration is added, files are not locally cached,
; will speed up tests but decrease performances
;
; chosen environment will also be available in your unix env ENVIRONMENT variable
;
; default: production
;
environment=development

How do you adjust your PHP preferences?

.

Which version(s) of PHP are available?

If your site uses a CMS, such WordPress, Joomla, and PrestaShop, you will find useful information on its official website or in the admin space of the module. If the CMS you use continues to be provided by the publisher and your version is up-to-date, it should be able to support the latest PHP updates. Most CMS have a simple update tool allowing you to perform updates easily. Some update automatically, like WordPress version 3.7 and onwards (2013 amd onwards).

If your site is based on your own development or another customised solution, you will need to find out which version(s) of PHP would be supported.

For information, here is the list of updates that are incompatible with different versions of PHP:
> from PHP 4 to PHP 5: http://php.net/manual/en/migration5.incompatible.php
> from PHP 5.1 to PHP 5.2: http://php.net/manual/en/migration52.incompatible.php
> from PHP 5.2 to PHP 5.3: http://php.net/manual/en/migration53.incompatible.php
> from PHP 5.3 to PHP 5.4: http://php.net/manual/en/migration54.incompatible.php
> from PHP 5.4 to PHP 5.5: http://php.net/manual/en/migration55.incompatible.php
> from PHP 5.5 to PHP 5.6: http://php.net/manual/en/migration56.incompatible.php
.

How do you migrate to another version of PHP?

Once you know which version of PHP you need to use, you must specify the version in the .ovhconfig file, as we explained earlier in this guide.

If you want to check that your settings are correct, you can put your web server into "development" mode to check and correct any errors. To do this, in the .ovhconfig file change the "environment" setting "production" to "development".