mod fcgid php,Php-fcgid - HTTPD - Apache Software Foundation

Running PHP with fcgid

Why ?

Because mod_php forces you to load prefork MPM, which is inefficient.

Because mod_php will be loaded into httpd's memory even when serving static pages

Most distributions shipping in 2013 provide pre-compiled packages that let you run php with fcgid. This is just a matter of configuration.

mod_fcgid is an official Apache module, available at http://httpd.apache.org/mod_fcgid/

Benefits

Huge performance boost, both in CPU and memory consumption

PHP runs into a separated process

On what conditions not to run php on fcgid

If you run httpd 2.4, you should consider PHP-FPM

Quick How to

Follow ALL steps, or something will be missing in the end.

Unload mod_php by commenting out the LoadModule directive from your configuration. 2. Load the mod_fcgid module with the LoadModule directive. 3. Install PHP as CGI using your package manager. 4. Write a small wrapper, such as this : /usr/local/bin/php-wrapper

#!/bin/sh

# Set desired PHP_FCGI_* environment variables.

# Example:

# PHP FastCGI processes exit after 1000 requests by default.

PHP_FCGI_MAX_REQUESTS=1000

export PHP_FCGI_MAX_REQUESTS

# Replace with the path to your FastCGI-enabled PHP executable

exec /usr/lib/cgi-bin/php5

Make sure it is readable and executable by the apache user/group.

5.#5 Configuration - httpd.conf LoadModule fcgid_module /mod_fcgid.so

AddHandler fcgid-script .php

FcgidWrapper /usr/local/bin/php-wrapper .php

6.#6 Replace prefork MPM with a threaded MPM, such as worker. On 2.4, you can now change the active mpm by loading the appropriate module.

FAQ / It doesn't work

Don't panic. Check apache httpd error log.

PHP files are downloaded, not interpreted

If you have a handler already set for PHP, it may be conflicting. So you can try something like :

"grep -ri handler /etc/httpd | grep php" depending on the result, you may need to comment out some config you are having.

Further options

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值