Is php5 available? How do I use php5 alongside php4?

All shared servers have php5 along with php4. New servers are being setup with PHP5 as default where old servers still have php4 as default. Please note the following important points:

1. To use specific php for all *.php files as default in your entire account, you need to edit ~/public_html/.htaccess file and add any of the following directive for respective php version:

For PHP5:
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php .php5 .php4 .php3 .phtml

For PHP4:
# Use PHP4 as default
AddHandler application/x-httpd-php4 .php .php5 .php4 .php3 .phtml

(the first marker comment is mandatory now, see this article)

This will make the server process all files named .php or .php4 or .php3 or .phtml or .php5 by respective PHP Handler.

After this change, no files under public_html will be processed by other PHP version.

If you want to use both php4 and php5 and the server your account is on has PHP4 as default then you can create a sub folder in public_html say "test5" and add the above mentioned PHP5 directive in .htaccess there. This way php5 will be used only under that "test5" folder and the folder tree under it, and rest of your account will continue to use php4.

2. To make changes to php configuration, you will need to install php.ini in working folder. We have placed a typical default php.ini file for php5 here:

Please rename it to php.ini


NOTE: In the current php implementation, php will pick php.ini in the following precedence:

folder defined in .htaccess using suPHP_ConfigPath directive(higher precedence) >> working folder >> default global php.ini (at server level)

suPHP_ConfigPath directive expects a path name so do not refer to a file but to the directory the file resists in.

Example: If you want to use "/home/username/php-config/php.ini", use "suPHP_Config /home/username/php-config".

3. If you set the config path using suPHP_ConfigPath directive, then that setting will be applied to entire account unless modified for any other folder. This will give you the ease of making config change at one place only and the changes will be reflected to entire account.

4. suPHP_ConfigPath directive containing .htaccess can be placed outside the webroot for security reasons.

5. register_globals is off by default and will remain off. It is said that php6 will not have register_globals, so it is a good time to fix your scripts not to depend on it. But if you need to turn it on, you can do that using your php.ini file.

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

PHP4 end of life announcement, what do I need to do?

php.net has posted this announcement 13-Jul-2007:Today it is exactly three years ago since PHP 5...

I want to use php sessions without cookies?

This is a development issue and is explained in the php manual:http://www.php.net/sessionThere is...

Can I run PHP scripts anywhere on my site?

Yes, PHP scripts do not have to reside in a particular directory and will run anywhere on your...

What are some basic software paths?

Sendmail: /usr/lib/sendmailPerl5: /usr/bin/perlServerpath: /home/username/public_htmlRoot path:...

What is PHP and how do I use it?

PHP is a powerful, server-side scripting language that can be used to extend the functionality of...