What's wrong with my htaccess?

Hi - have a simple problem here. I’m trying to use a custom php.ini, so I followed http://wiki.dreamhost.com/PHP.ini. I made my cgi-bin folder (subdomain.dreamhosters.com/cgi-bin), and successfully copied php.ini & php.cgi. Then I copy and paste, using pico, the exact text of the .htaccess file into a new .htaccess in subdomain.dreamhosters.com. I try a phpinfo(), and get a 500 error. Of course if I delete my .htaccess then phpinfo() works, from the DH php.

I am positive that php.cgi and php.ini are both in the cgi-bin folder, which is in my subdomain.dreamhosters.com folder.

Seems like it should’ve been easy, any idea what went wrong?

How did you try the phpinfo()? I have a script called version.php on my websites with the following:

<?php echo phpinfo(); echo "\n"; ?>

Mine is similar, simply <?php phpinfo(); ?>. This works fine when I delete or remove the .htaccess file, which is why i believe the problem is there. What could it be?

Either your htaccess file is improperly formatted, or it’s syntax. By formatting, I mean something like creating it in Notepad and then uploading with bad linefeeds.

Anyhow, post it here and X out any sensitive info and we’ll look at it.


The file is simply:

Options +ExecCGI
Action php-cgi /cgi-bin/php.cgi
AddHandler php-cgi .php

… which I copied from the wiki, so I don’t think its the syntax. Formatting sounds more likely, what is the proper way to write and upload the file then?

Weird, my .htaccess looks like this:

Options (plus)ExecCGI AddHandler php-cgi .php Action php-cgi /cgi-bin/php.cgi
Maybe order matters.

As for formatting, I do most of my text editing in either vi or BBEdit. Those always seem to work.


Switched order, still no good. I made edits with vi, made sure that the it was exactly the same (see below), and i’m still getting the 500 error. Really stumped.

Options +ExecCGI
AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi

Does the cgi-bin directory have both the .cgi and .ini files? Did you run the php-copy.sh script, and did it give any warnings or errors?

Which setup did you use? PHP4, PHP5, or the General script? Is your website (under Domains -> Manage Domains -> Edit) set to run PHP4 or PHP5?


Both the .cgi & the .ini are in the cgi-bin folder. I copied, pasted and executed the php-copy.sh script for PHP5 (where the first two lines were changed to read:


The script went fine, it was creating the .htaccess that killed the progress. I used the PHP5 script, should I try the General one instead?

Is your site set to run as PHP5? Check under Manage Domains.


Yes it is. And when I remove or rename the faulty .htaccess file DH’s PHP 5.2.6 takes over fine.

Solved - I asked DH support, and they helped even though this is related to custom php.ini stuff. It worked, but the answer was so over my head I need to share it. Thanks for the pointers folks.

Actually your .htaccess was 100% fine, nothing wrong with it. The part of apache that makes it so that your scripts run as your user didn’t like the permissions that you had set on your cgi-bin directory. Apparently if anyone except you can write to the directory, it won’t let you run the cgi (in this case php.cgi). Anyway, chmod g-w ./cgi-bin fixed everything.

Ok, interesting. Mine is also set to g-w, which is the default when you use the mkdir command.


An excellent security setting that will spare many DH “talented amateur web designers” the hand-wringing pain of a hacked site. :cool: