![]() |
|
|||||||
| Register | Superb Development Tutorials | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| View Poll Results: Did this help you install PHP as CGI on Dreamhost? | |||
| Yes |
|
0 | 0% |
| No |
|
0 | 0% |
| Voters: 0. You may not vote on this poll | |||
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
||||
|
Install PHP as CGI on DH
Install PHP as cgi tutorial for DH
Create a cgi-bin folder in your web directory /yourwebsite.com/cgi-bin Put these two files php-copy.sh and php-update.sh in your main website directory. /yourwebsite.com Create php as CGI php-copy.sh Code:
#!/bin/sh CGIFILE="$HOME/testsite.superbdevelopment.net/cgi-bin/php.cgi" INIFILE="$HOME/testsite.superbdevelopment.net/cgi-bin/php.ini" rsync -a /dh/cgi-system/php5.cgi "$CGIFILE" # REMOVE THE FOLLOWING LINE TO CREATE THE UPDATE-ONLY SCRIPT: cp /etc/php5/cgi/php.ini "$INIFILE" perl -p -i -e ' s/.*post_max_size.*/post_max_size = 100M/; s/.*upload_max_filesize.*/upload_max_filesize = 100M/; ' "$INIFILE" Code:
#!/bin/sh
test $# = 0 && exit 1
while test "$1";do
case $1 in
-php5) PHP=php5 ;;
-sm) shift; SM=$1 ;;
-rg) shift; RG=$1 ;;
-pms) shift; PMS=$1 ;;
-umfs) shift; UMFS=$1 ;;
-mqg) shift; MQG=$1 ;;
-met) shift; MET=$1 ;;
-mit) shift; MIT=$1 ;;
-ml) shift; ML=$1 ;;
*) D=$1 ;;
esac
shift
done
test "$D" || exit 1
test -d "$HOME/$D" || exit 1
CGI="$HOME/$D/cgi-bin"
mkdir -m0755 -p $CGI || exit 2
PHP=${PHP:-php}
SM=${SM:-On}
RG=${RG:-Off}
PMS=${PMS:-8M}
UMFS=${UMFS:-7M}
MQG=${MQG:-Off}
MET=${MET:-30}
MIT=${MET:-60}
ML=${ML:-8M}
CGIFILE="$CGI/$PHP.cgi"
INIFILE="$CGI/php.ini"
echo "CGI=$CGI MQG=${MQG} UMFS=${UMFS} PMS=${PMS} RG=${RG} SM=${SM} MET=${MET} MIT=${MIT} ML=${ML}" >&2
rsync -au /dh/cgi-system/$PHP.cgi "$CGIFILE"
[ -s /etc/$PHP/cgi/php.ini ] && \
sed -e "s/^safe_mode[ ]*=.*/safe_mode = $SM/" \
-e "s/register_globals[ ]*=.*/register_globals = $RG/" \
-e "s/magic_quotes_gpc[ ]*=.*/magic_quotes_gpc = $MQG/" \
-e "s/.*post_max_size.*/post_max_size = $PMS/" \
-e "s/.*upload_max_filesize.*/upload_max_filesize = $UMFS/" \
-e "s/.*max_execution_time.*/max_execution_time = $MET/" \
-e "s/.*max_input_time.*/max_input_time = $MIT/" \
-e "s/.*memory_limit.*/memory_limit= $ML/" \
chmod 0755 "$CGIFILE"
chmod 0644 "$INIFILE"
[ -s $CGI/.htaccess ] || echo "Options -Indexes" > $CGI/.htaccess
touch $HOME/$D/.htaccess
if grep -q '^Options' $HOME/$D/.htaccess; then
grep -q '+ExecCGI' $HOME/$D/.htaccess || \
sed -i 's/^Options\(.*\)/Options\1 +ExecCGI/' $HOME/$D/.htaccess
else
echo "Options +ExecCGI" >> $HOME/$D/.htaccess
fi
grep -q '^AddHandler[ ]\+php-cgi[ ]\+.php' $HOME/$D/.htaccess ||
echo "AddHandler php-cgi .php" >> $HOME/$D/.htaccess
if grep -q '^Action[ ]\+php-cgi' $HOME/$D/.htaccess; then
sed -i "s@^Action[ ]\+php-cgi.*@Action php-cgi /cgi-bin/$PHP.cgi@" \
$HOME/$D/.htaccess
else
echo "Action php-cgi /cgi-bin/$PHP.cgi" >> $HOME/$D/.htaccess
fi
If it is not then do the following /yourwebsite.com/cgi-bin/ Inside the cgi-bin directory create a .htaccess file with this code inside it: Code:
redirect 301 php.cgi http://yourwebsite.com redirect 301 php.ini http://yourwebsite.com Once your complete add this to the .htaccess file for your website content /yourwebsite.com Code:
Options +ExecCGI Options -Indexes AddHandler php-cgi .php Action php-cgi /cgi-bin/php.cgi
__________________
WOLFServers | The Game Administration | Superb Development | WOLFGaming Need help with your server, just want to talk or anything else, you can do it all at www.superbdevelopment.com Last edited by TheHeartSmasher; 02-16-2007 at 08:18 PM. |