Superb Development  


Go Back   Superb Development > Forum > Tech Talk > Webmasters, Developers and Designers

Tags: , ,

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

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-16-2007
TheHeartSmasher's Avatar
The Smasher
 
Join Date: Feb 2006
Location: Superb Development
Posts: 340
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"
To keep php up to date
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
Check your cgi-bin directory to make sure you have the following in your .htaccess file.
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
Run the two .sh scripts in your SSH console make sure you leave them at the defaults then you can go edit your php.ini file to your custom settings.

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

  Superb Development > Tech Talk > Webmasters, Developers and Designers

« - | - »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT -4. The time now is 11:45 AM.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO
Forum SEO by Zoints
Superb Development