本文共 1812 字,大约阅读时间需要 6 分钟。
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
<VirtualHost 192.168.1.2> DocumentRoot /usr/local/apache/htdocs ServerName ErrorLog logs/www.benet.com.error.log CustomLog logs/www.benet.com.access.log common </VirtualHost>:wq
访问
2.fcgi安装
# tar zxf fcgi-2.4.0.tar.gz
# cd fcgi-2.4.0 # ./configure # make && make installfcgi是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.soAddHandler fastcgi-script .fcgi
AddType application/x-httpd-php .php:wq
测试:
# vi /usr/local/apache/htdocs/test.php<?
phpinfo(); ?>:wq
访问:本文转自linux博客51CTO博客,原文链接http://blog.51cto.com/yangzhiming/835033如需转载请自行联系原作者
yangzhimingg