I use Hostgator for my website hosting since about 2006 and for the most part, they've done a fantastic job of uptime and customer service. Since I started with them back in the earlier PHP days, the server I've been assigned to, hasn't been updated to force PHP 5.3 by default yet so I'm stuck at PHP 5.2 (or PHP 4 if I so choose) except... I don't want it to default to PHP 5.2.
cPanel has an option that is enabled by Hostgator, to choose between major versions of PHP, so between 4 and 5 and since the default for 5 is 5.2, I'm kinda limited. Now, the article linked above, does mention adding the code to any .htaccess file:
# Use PHP 5.3
AddType application/x-httpd-php53 .php
But it doesn't work. You have to change AddType with AddHandler But wait! Don't go off and start changing anything yet! The article says to do it for your "sites" .htaccess and sure, it will do it there, but there's a MUCH easier place to set it once and be done with it. Something that doesn't even seem to be documented by Hostgator...
Remember I mentioned that you can force between PHP 4 or 5? Well, the place to set this is at PHP Configuration in your cPanel. You'll find it down in your Software/Services section. When you open up the PHP Configuration, you'll see up there at the top some text that says: "The ".php" file extension will be processed by ..." and a dropdown box with "System Default | PHP 4 | PHP 5". Let's set this to PHP 5. What this does for us, is creates a .htaccess file in the root folder of our account. The one that is before your public_html folder.
Open the .htaccess file and it will look something like this:
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
Note: Your file might have some other stuff like:
<IfModule mod_suphp.c>^M
suPHP_ConfigPath /home/youruser/php.ini^M
<Files php.ini>^M
order allow,deny^M
deny from all^M
</Files>^M
</IfModule>
Just ignore it. I have no idea what the ^M is for, but if yours has it, I'd say leave it.
Good, now let's make a small change and add a "3" so it looks like this (php5 -> php53):
# Use PHP53 as default
AddHandler application/x-httpd-php53 .php
That's it! If you have a PHP Info file setup to check your PHP version and details, it should immediately change from 5.2.x.x to 5.3.x.x and you're done. No more fiddling with manually adding the directive to each and every single new site! This will take care of EVERY php website within your public_html folder!
Post Comment