Настройка PHP для работы в 2х режимах, как модуль apache и как fastcgi.

Про­из­во­дим стан­дарт­ную связ­ку Apache + suEXEC + mod_fcgid как в дан­ной статье

Thank you for reading this post, don't forget to subscribe! 

[spoiler]

# This is the Apache server configuration file for providing FastCGI support
# through mod_fcgid
#
# Documentation is available at
# http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
LoadModule fcgid_module modules/mod_fcgid.so
# Use FastCGI to process .fcg .fcgi & .fpl scripts
AddHandler fcgid-script fcg fcgi fpl
# Sane place to put sockets and shared memory file
FcgidIPCDir /var/run/mod_fcgid
FcgidProcessTableFile /var/run/mod_fcgid/fcgid_shm
DirectoryIndex index.php
PHP_Fix_Pathinfo_Enable 1

mkdir -p /var/www/user1/php-cgi/

cat /var/www/user1/php-cgi/php.cgi

#!/bin/sh
PHPRC=/var/www/user1/php-cgi/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=500
exec /usr/bin/php-cgi

cat /etc/httpd/conf.d/test.t.conf
<VirtualHost *:8080>
ServerAdmin webmaster@test.t
DocumentRoot /var/www/user1/site/test.t
ServerName test.t
ServerAlias www.test.t
ErrorLog /var/www/user1/logs/test.t.error.log
CustomLog /var/www/user1/logs/test.t.access.log common
<IfModule mod_fcgid.c>
SuexecUserGroup user1 user1
<Directory /var/www/user1/site/test.t>
Options +ExecCGI
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /var/www/user1/php-cgi/php.cgi .php
Order allow,deny
Allow from all
</Directory>
</IfModule>
</VirtualHost>

[/spoiler]

 

Что­бы PHP рабо­тал как модуль apache нуж­но в кон­фиг фай­ле вир­ту­ал­хо­ста доба­вить запись:

[spoiler]<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule !prefork.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
AddType text/html .php
DirectoryIndex index.php[/spoiler]