Setup fastcgi on Media Temple DV for real (w/ extra troubleshooting tips... including dealing w/ fastcgi on MT w/ Drupal.)
While the (dv) 3.5 machines come with PHP5 and FastCGI by default, PHP is still setup to run as an Apache module rather than as a fcgi process.
I’m assuming you already know why you want to run PHP as CGI, so I won’t go into the benefits.
First, make backups. I don’t work for Media Temple, and I’ve never used their snapshot backup system, but it sure looks like a fast and convenient way for making a full backup of the machine.
Now, here’s the blow-by-blow (adapted from this KB article). These instructions must be followed for each domain, though there’s probably a way to make it the default - perhaps by modifying httpd.conf.:
1. Enable root acccess, CGI, and FastCGI for the machine / domain in question.
2. On my machine, Safe Mode was on by default (doesn't matter either way for this), so I’m skipping the Safe Mode step from the KB article.
3. Find out the FTP username for the domain. This is the username under which PHP will run (the point of this is so that PHP will have permission to access the files and folders that you uploaded via FTP, which will be owned by the FTP user). MAKE SURE YOU HAVE CHECKED SHELL ACCESS IN PLESK!!!! I used /bin/bash.
4. Log in via SSH as root and navigate to the directory for the domain (/var/www/vhosts/yourdomain.com/).
5. Copy the CGI version of PHP to the bin directory and change ownership as so (replace “username” with the FTP username you found above) with these commands:
cp /usr/bin/php-cgi bin/
chown -R username:psacln bin
(!NOTE!: psacln may not be correct, make sure of the group name, could be psaserv on some, this caused me problems for hours, as I have multiple DV's with 3.5.)
6. Open / create vhost.conf for editing:
cd conf
vi vhost.conf
7. Add the following lines to vhost.conf, replacing “yourdomain.com” with your actual domain name:
AddHandler fcgid-script .php .php5
SuexecUserGroup username psacln
<Directory /var/www/vhosts/yourdomain.com/httpdocs>
FCGIWrapper /var/www/vhosts/yourdomain.com/bin/php-cgi .php
Options ExecCGI
allow from all
</Directory>
8. Save vhost.conf, quit vi, and restart the webserver:
/usr/local/psa/admin/sbin/websrvmng -a -v
9. Test by creating a phpinfo() file in your web directory and visit it with the browser. You should see “CGI/FastCGI” on the Server API line (right after the configuration info):
ServerAPI CGI/FastCGI
The new system should still be using /etc/php.ini for configuration. Note that the default php.ini configuration is not considered to be secure and should be reviewed. Which... if you have trouble with Drupal still:
There was an issue with my index.php that caused it to generate Notice: errors before the rest of the script output when parsed by PHP, so I needed to set error_reporting to E_ERROR in my /etc/php.ini instead of E_ALL to prevent those notices from being interpreted by FastCGI as a premature end of script headers. Then it ran fine (Drupal 6.)
- Technology:


Comments
sorry rahul
this happens from misconfiguration.... i'll try and conact you to get your specifics
FYI a very helpful Media Temple Guy referenced your post
So thanks for saving me and the tech time.
Hi
Hi Matty,
First thanks for clean and nice tutorial.
I followed everything as per your instructions but ended up getting "500 Internal Server Error".
Any ideas, as why this must be happening??
Thanks,
-Rahul
Most of this is listed in the KB, but...
it's mostly for DV 3 vs. DV 3.5 with people attempting to show the difference.
Post new comment