Custom php.ini and .htaccess

software development

#1

Hi guys!
I followed this guide (http://wiki.dreamhost.com/Advanced_PHP_configuration) for a custom php configuration.
The thing is when i try to use the custom config with mod_rewrite I get a internal error.

in my .htaccess i have:


RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

Options ExecCGI
AddHandler php5-cgi .php
Action php5-cgi /php5/php5.cgi

without the mod_rewrite lines works fine. This is the error when i use mod_rewrite:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@domain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Probably is an error in the .htaccess config, but I can’t solved it.

Thanks a lot and sorry by mi english…


#2

Delete (or rename) cgi-bin and .htaccess and use the PHP.INI installer

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#3

Thanks sXi, i tried that but still doesn’t work. works fine after install but i need these lines in the .htaccess (needed by Cakephp to work properly):



RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

And with these lines got the same 500 error…

the errorlog says:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace.


#4

Just tested this and it worked:

AddHandler php-cgi .php Action php-cgi /cgi-bin/dispatch.cgi <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule>Check your logs to see if Cake is adding extra stuff to the URL.

$ /home/ [username] /logs/ [domain.com] /http/error.log

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#5

I cannot find the dreamhost wiki article anymore, but I came across the files described below a couple of years ago when trying to add php.ini to some domains from a location that blocked me from using the needed SSH session required for most of the other php/php.ini wiki articles.

On domains where I want a custom php.ini so I can edit some settings I simply drop two files into the root of that domain before setting up the web application and access the php file via a web browser and voila, php.ini is setup.

As I cant attach files here, I will post the text and you can save it as the relevant type. Save everything in between (but not including) the line of =============== at the top and bottom of each list of commands.

FILE 01: save as custom_php_ini.php

==============================================

<?php shell_exec('chmod 755 custom_php_ini.sh'); $mode=$_GET['mode']; $command="./custom_php_ini.sh $mode"; if($mode == "" || $mode == "test" || $mode == "php4" || $mode == "php5") { $output = shell_exec($command); } echo "
$output
"; ?> Test PHP5 PHP4

FILE 02: save as custom_php_ini.sh

==============================================
#!/bin/sh

path=pwd

if [ -z “$1” ]; then
echo "Usage: $0 "
echo
echo "Arguments:"
echo "test: test to make sure things look good"
echo "php4: install custom php4"
echo "php5: install custom php5"
exit 1
fi

if [ $1 = “test” ]
then
echo Path to your domain is: $path
echo
echo "To execute:"
echo mkdir $path/cgi-bin
echo cp -pvf /dh/cgi-system/phpX.cgi $path/cgi-bin/php.cgi
echo cp -vf /etc/phpX/cgi/php.ini $path/cgi-bin/php.ini
echo cat $path/.htaccess “>” $path/.htaccess.temp
echo echo AddHandler php-cgi .php “>” $path/.htaccess
echo echo Action php-cgi /cgi-bin/php.cgi “>>” $path/.htaccess
echo echo ">> "$path/.htaccess
echo cat $path/.htaccess.temp “>>” $path/.htaccess
echo rm $path/htaccess.temp
echo
echo chmod 644 $path/.htaccess
echo chmod 755 $path/cgi-bin
echo chmod 750 $path/cgi-bin/php.cgi
echo chmod 644 $path/cgi-bin/php.ini
echo wget -O $path/info.php http://dhspeedtest.com/info.txt

fi

if [ $1 = “php4” ]
then

mkdir $path/cgi-bin
cp -pvf /dh/cgi-system/php.cgi $path/cgi-bin/php.cgi
cp -vf /etc/php/cgi/php.ini $path/cgi-bin/php.ini
cat $path/.htaccess > $path/.htaccess.temp
echo AddHandler php-cgi .php > $path/.htaccess
echo Action php-cgi /cgi-bin/php.cgi >> $path/.htaccess
echo >> $path/.htaccess
cat $path/.htaccess.temp >> $path/.htaccess
rm $path/.htaccess.temp
chmod 644 $path/.htaccess
chmod 755 $path/cgi-bin
chmod 750 $path/cgi-bin/php.cgi
chmod 644 $path/cgi-bin/php.ini
wget -O $path/info.php http://dhspeedtest.com/info.txt

fi

if [ $1 = “php5” ]
then
mkdir $path/cgi-bin
cp -pvf /dh/cgi-system/php5.cgi $path/cgi-bin/php.cgi
cp -vf /etc/php5/cgi/php.ini $path/cgi-bin/php.ini
cat $path/.htaccess > $path/.htaccess.temp
echo AddHandler php-cgi .php > $path/.htaccess
echo Action php-cgi /cgi-bin/php.cgi >> $path/.htaccess
echo >> $path/.htaccess
cat $path/.htaccess.temp >> $path/.htaccess
rm $path/.htaccess.temp
chmod 644 $path/.htaccess
chmod 755 $path/cgi-bin
chmod 750 $path/cgi-bin/php.cgi
chmod 644 $path/cgi-bin/php.ini
wget -O $path/info.php http://dhspeedtest.com/info.txt
fi

==============================================

When you have saved these files as custom_php_ini .php and .sh simply drop them into the root of the relevant directory (eg. /home///) and navigate to http:///custom_php_ini.php on your web browser. Its an old file so offers php4 or php5 but simply choose php5 and hit the submit button and your cgi folder, php.ini and htaccess are created. For htaccess it creates or adds the following line to the .htaccess file

AddHandler php-cgi .php
Action php-cgi /cgi-bin/php.cgi

I can then edit php.ini to my hearts content …