• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

How do I run PHP over FastCGI?

barbutti

New Pleskian
I have a clean install of Plesk 8.3 and I want to run PHP through FastCGI.
How should I proceed?

I created the domain with the "FastCGI support" checked; what exactly does that mean?

Thanks in advance.
 
This is fairly easy but need some extra work.

First you need to check that you have a php binary on your system that will work for cgi. For example in my case:

[root@control2 cgi-bin]# /usr/local/php525-fcgi/bin/php-cgi -v
PHP 5.2.5 (cgi-fcgi) (built: Nov 28 2007 12:31:32)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies
with Zend Optimizer v3.3.0, Copyright (c) 1998-2007, by Zend Technologies

Next step, is create a php5.fcgi file in the given domain's cgi-bin folder. I am going to use the domain mydomain.com to make it easier.

/var/www/vhosts/mydomain.com/cgi-bin/php5.fcgi
#!/bin/sh
PHP_FCGI_CHILDREN=2
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /usr/local/php525-fcgi/bin/php-cgi
edit: I forgot to mention, you need to change the owner of this file to that of the domain user as well as preferably chmod 755, nothing higher and at least 500 I think to have it executable by the domain user.

Next step is configure apache but only for this specific domain.

/var/www/vhosts/mydomain.com/conf/vhost.conf
<Directory /var/www/vhosts/mydomain.com/httpdocs>
Action application/x-httpd-php5 /cgi-bin/php5.fcgi
AddType application/x-httpd-php5 .php
</Directory>

/var/www/vhosts/mydomain.com/conf/vhost_ssl.conf
<Directory /var/www/vhosts/mydomain.com/httpsdocs>
Action application/x-httpd-php5 /cgi-bin/php5.fcgi
AddType application/x-httpd-php5 .php
</Directory>

Now if those vhost.conf files didn't exist you need to run the following command first:
/usr/local/psa/admin/bin/websrvmng -av

then just double check your files that there is no problem:
httpd -t
Should give the output:
Syntax OK

Whether the vhost.conf was new or not, now reload the config files on apache (centos in my case)
/etc/init.d/httpd reload

Go create a info.php in /var/www/vhosts/mydomain.com/httpdocs with the following:
<?php phpinfo(); ?>

Visit http://www.mydomain.com/info.php and verify your php version.
 
Not if you want to run multiple versions of php on 1 server.
 
I know, but is better to have 1. People should upgrade or accept to stay on an older server with PHP4. It is a common problem, I know. :-(
 
Back
Top