How to use PHP versions, 4, 5.2, 5.3, 5.4 and 5.5 on your site?

Helpful? Let Us Know

To maximise compatibility, we have many versions of PHP already installed on our servers.

To set the version of PHP for your website, just add the following to your site's .htaccess file.

You can find the .htaccess file in either the top-most directory for your site, or the public_html folder:

For PHP 4:

SetEnv DEFAULT_PHP_VERSION 4

For PHP 5.2:

SetEnv DEFAULT_PHP_VERSION 5

For PHP 5.3:

SetEnv DEFAULT_PHP_VERSION 53

For PHP 5.4:

SetEnv DEFAULT_PHP_VERSION 54

For PHP 5.5:

SetEnv DEFAULT_PHP_VERSION 55

This should always be at the top of a .htaccess file.

Remember that the .htaccess file of a subfolder will always override the one in its parent folder, so if the version as set as 5.3 in one folder, and afolder containing the site within that folder contains another .htaccess file that specifies PHP 5.2 to be used, PHP 5.2 will be the one that's used.

You can use this to set sub-sites within a website to use different versions of PHP.

To set the PHP version for when running a cron command

The above just tells Apache what the default version of PHP should be on a website, and so doesn't take affect command lines such as those used in cron tasks.

If you need to run a PHP file as a cron task using a specific version of PHP, you just need to specify the version in the path to the interpreter.

These are as follow:

For PHP 4:

/usr/bin/php4 /the/path/to/the/php/file/to/be/run AndArgument1 AndArgument2

For PHP 5.2:

/usr/bin/php5 /the/path/to/the/php/file/to/be/run AndArgument1 AndArgument2

For PHP 5.3:

/usr/bin/php53 /the/path/to/the/php/file/to/be/run AndArgument1 AndArgument2

For PHP 5.4:

/usr/bin/php54 /the/path/to/the/php/file/to/be/run AndArgument1 AndArgument2

For PHP 5.5:

/usr/bin/php55 /the/path/to/the/php/file/to/be/run AndArgument1 AndArgument2

Related Articles

Before you install Locked Area Lite you need to create a folder that you want to protect - this should be inside your public_html folder. When you carry out the installation, it...

A '403 Forbidden' message means that the browser has requested a page that it is not permitted to view. There are a few common causes:- - Missing or incorrectly named index file...

You can decrease load times on your website by compressing the contents. You can do this on any website (home-made, WordPress, Joomla, etc.) with gzip using...

HTML is the stuff dreams are made of. If you're a website developer, anyway. HTML stands for HyperText Markup Language (in case you go to many pub quizzes), and is the basic...

The path to your website is partially determined by your domain name, but is in the following format: /home/sites/your-domain-name.com/public_html If you are...

Was this answer helpful?

 Print this Article