leonheart 发表于 2018-11-28 08:11:50

apache+fastcgi+php

  apache+fastcgi+php配置
  
1、安装apache
  下载地址:http://httpd.apache.org/download.cgi
  
# 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            (在最后编写)
  NameVirtualHost192.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
  访问 http://www.benet.com
  
2.fcgi安装
  http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
  # tar zxf fcgi-2.4.0.tar.gz
# cd fcgi-2.4.0
# ./configure
# make && make install
  fcgi是fastcgi的开发包,需要在mod_fastcgi之前安装
  
3.mod_fastcgi安装
  http://www.fastcgi.com/dist/mod_fastcgi-2.4.6.tar.gz
  
# 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
  
  :wq
  
访问:http://www.benet.com/test.php



页: [1]
查看完整版本: apache+fastcgi+php