Enabling FastCGI on MediaTemple

This article applies to enabling FastCGI support for PHP scripts on MediaTemple hosting.

Following sequence of commands/actions as mentioned below. Order is important!

1. Check how your PHP scripts are served?

Create a file with name “info.php” on your domains webroot directory – example path:** “/var/www/vhosts/example.com/”**

Add following codes in it.** **

<?php phpinfo(); ?>

After saving file like above access URL from browser: http://example.com/info.php

In output, look for option Server API **and its value. It must be **”CGI/FastCGI”.

In following screenshot, originally taken from a domain on MediaTemple account you can see below Server API is set to “Apache 2.0 Handler”

** **

2. Login via Plesk panel and enable CGI as well as FASTCGI support for the domain in question, say for example.com

For domain in question, make sure following options are configures:

  • PHP – Enabled
  • PHP ‘safe_mode’ – Disabled
  • CGI – Enabled
  • FastCGI – Disabled

See following screenshot for reference:

3. Login as root over SSH and execute following commands

1. Move to webroot directory for exmaple.com

cd /var/www/vhosts/example.com

2. Copy php-cgi file to bin sub-directory under **example.com **

cp /usr/bin/php-cgi bin/

3. Change owner for bin directory and its content (that includes php-cgi file)

chown -R username:psacln bin

(replace username with your FTP login name for this domain)

4. Create a vhost.conf file in conf sub-directory under **example.com **

vi conf/vhost.conf

5. Paste following content in that file. DO NOT forget to replace example.com with your actual domain name.* *

AddHandler fcgid-script .php .php5
<Directory /var/www/vhosts/example.com/httpdocs>
   FCGIWrapper /var/www/vhosts/example.com/bin/php-cgi .php
 allow from all

6. Run following command so that Plesk will update its configuration including apache server restart

/usr/local/psa/admin/sbin/websrvmng -a -v

7. Jump to the first step and verify PHP Server API. It should now look like as highlighted in following screenshot.

8.DO NOT forget to change owner of files that were created using PHP running as Apache module

chown -R username:psacln *

(replace username with your FTP login name for this domain)