本页主题: Using PHP with fcgid & suexec on Apache 2.2 打印 | 加为IE收藏 | 复制链接 | 收藏主题 | 上一主题 | 下一主题

admin
级别: 管理员


精华: 1
发帖: 4646
威望: 47 点
金钱: 23190 RMB
贡献值: 0 点
注册时间:2006-10-09
最后登录:2008-11-22

 Using PHP with fcgid & suexec on Apache 2.2

Using PHP with fcgid & suexec on Apache 2.2
(Version française)
In short
This page summaries a working setup of PHP on Apache, using fcgid and suexec. It has been tested with Apache 2.2 on a Debian Linux system.
Installation procedure
Customisation
You need to adapt the following values to your own setup:
user_account: the user account under which your PHP scripts will run.
user_group: the group that will be used to run your PHP scripts.
www-data: the user account used by Apache.
php_site: the directory under which your web site will be installed.
/usr/bin/php-cgi: the full path to your PHP interpreter1. It will need to support the FastCGI2 interface.
Apache 2 setup
Enable the fcgid et suexec Apache modules. If you're using a Debian, this can be done with the following commands:
a2enmod suexec
a2enmod fcgid
Modifiy your virtuals hosts as follows:
DocumentRoot /var/www/user_account/php_site
[...]
Options None
SuexecUserGroup user_account user_group
  # The PHP scripts in this directory
  # are run through the php-cgi script.
  AddHandler fcgid-script .php
  FCGIWrapper /var/www/user_account/php-cgi .php
  Options ExecCGI
# We run a single PHP FastCGI server
# which will launch as many children
# as necessary.
DefaultMaxClassProcessCount 1
DefaultMinClassProcessCount 1
You now need to check that you Apache is correctly set up:
apache2ctl -t
Directory structure creation
Unless you use the mod_userdir Apache module, your will need to work in a subdirectory of /var/www.
First, create the directories that will contain your site:
mkdir -p /var/www/user_account/php_site
Then copy your files in the php_site directory.
Wrapper script
Place the following script in a file called php-cgi, in the /var/www/user_account directory:
#!/bin/sh
export PHP_FCGI_CHILDREN=4
export PHP_FCGI_MAX_REQUESTS=500
exec /usr/bin/php-cgi $@
When this script is started by Apache, it will automatically be replaced by the php-cgi process. This process will start 4 chilren, to process the incoming requests. Once a child will have processed 500 requests, it will automatically shutdown and be restarted by the initial process. This feature is here to prevent a possible memory leak.
Your should adapt the number of children (PHP_FCGI_CHILDREN) to suit your needs. A lower value (e.g. 4) will be less demanding on your server. A higher value (e.g. 8) will enable your server to handle more connexions.
Permissions update
Apply the following permissions:
# User account directory
chown user_account:user_group /var/www/user_account
chmod u=rwx,g=rx,o=rx /var/www/user_account
# Wrapper script
chown user_account:user_group /var/www/user_account/php-cgi
chmod u=rwx,ug= /var/www/user_account/php-cgi
# Site
chown user_account:www-data /var/www/user_account/php_site
chmod -R u=rwX,g=rX,o= /var/www/user_account/php_site
Restart Apache
Everything should be OK now, you just need to restart Apache:
apache2ctl graceful
See also
The SUEXEC documentation of the Apache project.
The mod_fcgid short documentation.
The README.FastCGI file, which is included in the PHP sources.


by http://wiki.tigreraye.org/Using_PHP_with_fcgid_&_suexec_on_Apache_2.2
顶端 Posted: 2007-06-26 01:47 | [楼 主]
帖子浏览记录 版块浏览记录
承德互联 » unix专区

Total 0.288276(s) query 5, Time now is:11-22 16:29, Gzip enabled
Powered by PHPWind v6.3.2 Certificate Code © 2003-08 PHPWind.com Corporation