apache fastcgi php,apache+fastcgi+php

养研
2023-12-01

apache+fastcgi+php配置

1、安装apache

# tar zxf httpd-2.2.9.tar.gz -C /usr/src

# cd /usr/src/httpd-2.2.9

# ./configure    --prefix=/usr/local/apache  --enable-so --enable-mods-shared=all  --enable-rewrite --enable-ssl --with-ssl=/usr/lib  --enable-auth-digest --enable-cgi --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/usr/local/apache/htdocs

# make && make install

# cd /usr/local/apache/conf

# ls

# cp httpd.conf httpd.conf.bak

# grep -v "#" httpd.conf.bak   | grep -v "^$" > httpd.conf

# cd /usr/local/apache/htdocs

# vi /usr/local/apache/conf/httpd.conf            (在最后编写)

NameVirtualHost  192.168.1.2

DocumentRoot         /usr/local/apache/htdocs

ServerName           www.benet.com

ErrorLog             logs/www.benet.com.error.log

CustomLog            logs/www.benet.com.access.log     common

:wq

2.fcgi安装

# tar zxf fcgi-2.4.0.tar.gz

# cd fcgi-2.4.0

# ./configure

# make && make install

fcgi是fastcgi的开发包,需要在mod_fastcgi之前安装

3.mod_fastcgi安装

# tar zxf mod_fastcgi-2.4.6.tar.gz

# cd mod_fastcgi-2.4.6

# cp Makefile.AP2 Makefile

# vi Makefile

top_dir =/usr/local/apache

:wq

# make && make install

4. php的编译方式(版本php5.x)

# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc  --enable-fastcgi --enable-force-cgi-redirect --disable-cli --with-apxs2=/usr/local/apache/bin/apxs

# make && make install

安装成功后,执行

php -v 输出

PHP 5.1.4 (cgi-fcgi).

这里输出带了cgi-fcgi

如果编译时不加--disable-cli则输出

PHP 5.1.4 (cli).

5.apache配置

以上安装完后,需要配置apache来以fastcgi模式运行php程序。

# vi /usr/local/apache/conf/http.conf

LoadModule php5_module        libexec/libphp5.so

LoadModule fastcgi_module     libexec/mod_fastcgi.so

AddHandler fastcgi-script .fcgi

AddType application/x-httpd-php .php

:wq

测试:

# vi /usr/local/apache/htdocs/test.php

phpinfo();

?>

:wq

 类似资料: