Производим стандартную связку Apache + suEXEC + mod_fcgid как в данной статье
Thank you for reading this post, don't forget to subscribe!
1 |
Вкратце: |
[spoiler]
1 2 |
yum -y install httpd php-common mod_fcgid php-cgi php mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.bkp |
1 |
cat /etc/httpd/conf.d/fcgid.conf |
# 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
# 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
1 |
редактируем файл <strong><code>/etc/php.ini </code></strong> cgi.fix_pathinfo=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
PHPRC=/var/www/user1/php-cgi/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=500
exec /usr/bin/php-cgi
1 |
Обязательно устанавливаем права и владельца: |
1 2 3 4 5 6 |
# chmod 755 /var/www/user1/php-cgi/php.cgi # chown -R user1:user1 /var/www/user1/php-cgi/ mkdir -p /var/www/user1/site/test.t/ chown -R user1:user1 /var/www/user1/site/test.t/ touch /var/www/user1/logs/test.t.error.log touch /var/www/user1/logs/test.t.access.log |
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>
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]
1 2 3 |
Т.е. когда уже переименован php.conf mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.bkp и подключен fastcgi |