posted by kevin on September 24, 2009

I recently created a site that had to be deployed on a GoDaddy server and it took a little playing around with the configuration before I could achieve what I wanted to do.

My main goal was to parse my .html and .php files using PHP5 as well as assigning a value to auto_prepend_file to my prepend file so I didn't have to include it on every page explicitly.

It's simple once you know, but here is how you achieve the two. Hopefully this helps at least one person out.

Godaddy, parse files as PHP

In the root of your site create an .htaccess file. Mine simply contained:

 
AddType application/x-httpd-php5 .htm .html .php
AddHandler x-httpd-php5  .htm .html .php
 

As you guessed this tells apache to parse .htm, .html, and .php files using PHP5.

Normally I'd include my php settings as PHP_Flag or PHP_Value in my .htaccess file, but godaddy does not allow this. So you need to do this.

Godaddy PHP5 INI settings

Create a file named php5.ini <--- Notice it's php5.ini not just php.ini

 
auto_prepend_file = /home/content/my/path/to/home/html/includes/prepend.php
 

You can include your other PHP ini settings in there, however that's all I needed.

10 comments to "GoDaddy PHP5 .htaccess and PHP INI settings"

#103
Max says:
January 18, 2010 at 08:26 pm
Hey thanks, I had problems installing vtiger because I was limited to php.ini but by adding the php5.ini it works great now. Many thanks.
#112
James says:
March 15, 2010 at 01:38 pm
Excellent post. I figured out eventually that because GoDaddy runs PHP as CGI rather than as an Apache module that you cannot change include_path using .htaccess files. This is the best work around I can find. Should work out well for managing the same site in several environments. Development/Production etc... Thanks again!
#114
Apple says:
March 26, 2010 at 01:16 pm
Thank you, great article. I am so confused though. Does godaddy run PHP as Apache or CGI on their shared linux hosting accounts? Is there an easy way to find this out with FTP access? Thank you very much. (3-26-2010)
#115
March 26, 2010 at 03:08 pm
@Apple, It's running as 'CGI/FastCGI' The best way to find that out through ftp is to create a phpinfo file, upload it to the server, and hit it with your browser. I.E.
 
<?php
phpinfo();
?>
 
Thanks.
#116
Apple says:
March 26, 2010 at 03:34 pm
Hi Kevin, Thank you. I found the following phpinfo so pretty sure it is CGI. Configure Command: './configure' '--enable-fastcgi' '--prefix=/usr/local/php5' '--with-config-file-path=/web/conf' '--disable-posix' '--enable-bcmath' '--enable-calendar' '--with-curl=/usr/bin/curl' '--with-gdbm' '--enable-exif' '--enable-ftp' '--with-gd' '--with-freetype-dir=/usr' '--with-jpeg-dir=/usr' '--with-png-dir=/usr/bin/libpng-config' '--enable-gd-native-ttf' '--with-gettext' '--with-mcrypt=/usr/bin/libmcrypt-config' '--with-mhash' '--with-mysql=/usr' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl' '--with-pdo-mysql=/usr' '--with-pspell' '--enable-soap' '--enable-wddx' '--with-xsl' '--with-zlib' '--enable-mbstring' '--enable-zip' Server API: CGI/FastCGI Let me buy you a coffee (PayPal). korb.kevin (at)g ?
#117
March 26, 2010 at 03:37 pm
You got it! Thanks.
#119
Corbin says:
April 18, 2010 at 12:52 am
Thanks, I've been developing some software and just threw it up on my godaddy host. I was setting the auto_prepend_file directive in the .htaccess but this wasn't working with godaddy. Your solution worked great
#130
Zac says:
May 12, 2010 at 10:41 pm
Thank you. This helped me a lot!
#152
Hasnain says:
June 25, 2010 at 09:53 am
Thanks, was very helpful.
#153
Josh says:
June 26, 2010 at 08:08 pm
Hey Guys -- The above fix for Godaddy did not work for me. I've tried everything, and spent a lot of time on the phone with the GB tech team.. still not able to use PHP code on any of my HTML pages. Please Help!
Bookmark and Share

Leave a Comment

Your email address will not be published.

(You can enclose code in <php></php> blocks.)

You may use Markdown syntax.

Please enter the letters as they are shown in the image above.
Letters are not case-sensitive.