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.

17 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!
#203
Alan says:
October 28, 2010 at 02:08 pm
Thanks, that worked! Godaddy sucks so badly. I've being trying for the last 10 hours to get two php apps to work on a godaddy hosted domain. All the time, I believed the hosting control panel as it says that the php version is 5.2.x; after runner php -v I can see that it's not. It's php 4.4.9!!!!!!!!! Thanks again, Alan
#216
Celia says:
November 12, 2010 at 06:28 am
Thanks so much it help me to resolved my problem , even the support from Goddady cant help me . After many hours to looking for i got it thanks again
#246
Bill says:
January 31, 2011 at 08:36 pm
In order for me to get this working on my GoDaddy host, I had to add this line above the two you indicate in my .htaccsss file (provided to me courtesy of GoDaddy support): Options +ExecCGI
#247
Evan says:
February 7, 2011 at 12:41 am
Might also be helpful to note that you can specify a relative path in the php5.ini file vs. an absolute path if you don't use sub-folders.
#248
Evan says:
February 7, 2011 at 12:50 am
The other thing I noticed, it does not work on files in subdirectories. What is the fix for that?
#252
February 23, 2011 at 05:20 am
Thanks for the info, I'm trying now to solve this problem for 2 weeks, tried everything, contacht godaady, no result I have made the .htaccess and php5.ini file , as you explaned, and uploded it ( 644) Do i have to wait before it will take effect or immediately, since i get : Forbidden You don't have permission to access /index.html on this server. Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request. -------------------------------------------------------------------------------- Apache Server at www.divingonkohtao.com Port 80
#280
Irfan says:
April 30, 2011 at 05:44 am
Thanks for your post nice one.Sir I tried this but not working on my hosting.i have godaddy shared hosting. Plz help me
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.