red hat 安装 php,Red Hat / CentOS Apache 2 FastCGI PHP安装

Instead of creating a new process for every request, FastCGI can use a single persistent process which handles many requests over its lifetime. Processing of multiple requests simultaneously is achieved either by using a single connection with internal multiplexing (ie. multiple requests over a single connection) and/or by using multiple connections. Many such processes can exist, something that can increase stability and scalability. FastCGI also allows programs to get the web server to do certain simple operations, like reading in a file, before the request is handed over. Environment information and page requests are sent from the web server to the process over a TCP connection (for remote processes) or Unix domain sockets (for local processes). Responses are returned from the process to the web server over the same connection. The connection may be closed at the end of a response, but the web server and the process are left standing.

Many web site administrators and programmers are finding that the separation of web applications from the web server in FastCGI (and the simpler SCGI) has many desirable advantages over embedded interpreters (mod_perl, mod_php, etc.). This separation allows server and application processes to be restarted independently — an important consideration for busy web sites. It also facilitates per-application security policies — important for ISPs and web hosting companies.

三、安装

1、先安装http服务 yum install libtool httpd-devel apr-devel apr

2、下载fastcgi源码包wget http://www.fastcgi.com/dist/mod_fastcgi-current.tar.gz

tar -zxvf mod_fastcgi-current.tar.gz

cd mod_fastcgi-2.4.6/

cp Makefile.AP2 Makefile

32位系统下的编绎安装:

make top_dir=/usr/lib/httpd

make install top_dir=/usr/lib/httpd

64位系统下的编绎安装:

make top_dir=/usr/lib64/httpd

make install top_dir=/usr/lib64/httpd

Configure mod_fastcgi

Open /etc/httpd/conf.d/mod_fastcgi.conf file

# vi /etc/httpd/conf.d/mod_fastcgi.conf

输入以下内容启用mod_fastcgi模块

LoadModule fastcgi_module modules/mod_fastcgi.so

重启http服务

# service httpd restart

如果想以fastcgi模式使用,你要先关闭mod_php模式

# mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.disable

创建一个shell脚本php.fcgi在cgi-bin目录

vim /var/www/cgi-bin/php.fcgi (或者存放到你站点的虚拟目录里)

内容如下:

#!/bin/bash

# Shell Script To Run PHP5 using mod_fastcgi under Apache 2.x

# Tested under Red Hat Enterprise Linux / CentOS 5.x

### Set PATH ###

PHP_CGI=/usr/bin/php-cgi

PHP_FCGI_CHILDREN=4

PHP_FCGI_MAX_REQUESTS=1000

### no editing below ###

export PHP_FCGI_CHILDREN

export PHP_FCGI_MAX_REQUESTS

exec $PHP_CGISet permission, type:

# chmod +x /var/www/cgi-bin/php.fcgi

最后,对DocumentRoot目录目录设置如下,使其运行在mod_fastcgi模式下

Options -Indexes FollowSymLinks +ExecCGI

AllowOverride AuthConfig FileInfo

AddHandler php5-fastcgi .php

Action php5-fastcgi /cgi-bin/php.fcgi

DirectoryIndex index.php index.html

Order allow,deny

Allow from all

#service httpd restart

mod_fastcgi虚拟主机配置

域名: XXX.com

网站主目录: /websites/home/XXX.com/http

cgi-bin目录: /websites/home/XXX.com/cgi-bin

php.fcgi路径: /websites/home/XXX.com/cgi-bin/php.fcgi

日志文件目录: /websites/home/XXX.com/logs

具体配置如下:

ServerAdmin webmaster@XXX.com

DocumentRoot "/websites/home/XXX.com/http"

ServerName XXX.com

ServerAlias www.XXX.com

ErrorLog "/websites/home/XXX.com/logs/error.log"

CustomLog "/websites/home/XXX.com/logs/access.log" common

ScriptAlias /cgi-bin/ "/websites/home/XXX.com/cgi-bin/"

Options -Indexes FollowSymLinks +ExecCGI

AllowOverride AuthConfig FileInfo

AddHandler php5-fastcgi .php

Action php5-fastcgi /cgi-bin/php.fcgi

Order allow,deny

Allow from all

AllowOverride None

Options None

Order allow,deny

Allow from all

虚拟目录创建的php.fcgi文件如下:

#!/bin/bash

PHP_CGI=/usr/bin/php-cgi

PHP_FCGI_CHILDREN=4

PHP_FCGI_MAX_REQUESTS=1000

export PHP_FCGI_CHILDREN

export PHP_FCGI_MAX_REQUESTS

赋予php.fcgi执行权限并重启http:

# chmod +x /websites/home/XXX.com/cgi-bin/php.fcgi

# service httpd restart

四、其他平台fast-cgi配置文件http://www.fastcgi.com/drupal/node/3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值