What's wrong with my htaccess?


#1

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?


#2

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

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


#3

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?


#4

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.

-Scott


#5

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?


#6

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.

-Scott


#7

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


#8

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?

-Scott


#9

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:

CGIFILE="$HOME/subdomain.dreamhosters.com/cgi-bin/php.cgi"
INIFILE="$HOME/subdomain.dreamhosters.com/cgi-bin/php.ini"

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?


#10

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

-Scott


#11

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


#12

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.


#13

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

-Scott


#14

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