• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

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