Server runs CentOs 6.10
Need to use php5 for some websites and php7 for others on the same server so I used the remi repository and enabled the php versions needed.
I've uninstalled mod_php and installed php-fpm and mod_fcgid.
In /etc/php-fpm.d/www.conf
, I've added:
listen = /var/run/php-fpm/www.sock
listen.group = apache
listen.mode = 0660
I have created /var/www/cgi-bin/php.fastcgi
with the following contents:
#!/bin/bash
PHPRC="/etc/php.ini"
PHP_FCGI_CHILDREN=4
PHP_FCGI_MAX_REQUESTS=1000
export PHPRC
export PHP_FCGI_CHILDREN
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php-cgi
Below is an example vhost for a domain:
<VirtualHost *:80>
# Admin email, Server name and Server alias
ServerAdmin [email protected]
ServerName domain.com
# Document Root settings
DirectoryIndex index.php
DocumentRoot /var/www/vhosts/domain.com/httpdocs/
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
# Logging settings
LogLevel warn
ErrorLog /var/www/vhosts/domain.com/log/error.log
CustomLog /var/www/vhosts/domain.com/log/access.log combined
</VirtualHost>
I've basically followed this guide but have also tried all sorts of other things from what I've found online, all to no avail.
If I visit a domain on the server, I just get a internal server error or the php is not parsed properly and just output as raw text.
What am I missing in the above configuration?
Using
php-cgi
is old and deprecated, you should use FPM service instead.See :
Notice: PHP-FPM is now the default way in Fedora and RHEL-8 (and thus in CentOS 8, when will be released)
P.S. Apache HTTP server version 2.2 in CentOS 6 doesn't support SetHandler to proxy, but you can use the httpd24 collection from SCL repository. I also recommend you to upgrade to a more recent CentOS version, 6 being very old and close to end of life.