使用mod_fcgid执行php脚本

使用mod_fcgid执行php脚本

文章目录
[隐藏]
  • 安装依赖
  • 安装apache 2.2
  • 安装mod_fcgid
  • 安装mysql
  • 安装php
  • 配置apache
  • 启动服务

安装依赖

  1. yum -y install gcc  gcc-c++ libtool-libs autoconf freetype-devel gd libjpeg-devel  libpng-devel libxml2-devel ncurses-devel zlib-devel curl-devel cmake patch  automake make  readline-devel openssl-devel  glibc-devel  glib2-devel bzip2-devel  libcap-devel   pcre-devel libmcrypt-devel

安装apache 2.2

  1. cd /tmp
  2. wget http://www.fayea.com/apache-mirror//httpd/httpd-2.2.22.tar.gz
  3. tar xzf httpd-2.2.22.tar.gz
  4. cd httpd-2.2.22
  5. ./configure --prefix=/usr/local/apache --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared  --enable-ssl=shared --enable-headers=shared --enable-rewrite=shared --enable-static-support
  6. make
  7. make install

安装mod_fcgid

  1. cd /tmp
  2. wget http://www.fayea.com/apache-mirror//httpd/mod_fcgid/mod_fcgid-2.3.7.tar.gz
  3. tar xzf mod_fcgid-2.3.7.tar.gz
  4. cd mod_fcgid-2.3.7
  5. APXS=/usr/local/apache/bin/apxs ./configure.apxs
  6. make && make install

安装mysql

  1. yum -y install mysql mysql-server mysql-devel

安装php

  1. #安装libmcrypt(只在centos 6进行)
  2. rpm -i http://centos.googlecode.com/files/libmcrypt-2.5.8-9.el6.i686.rpm
  3. rpm -i http://centos.googlecode.com/files/libmcrypt-devel-2.5.8-9.el6.i686.rpm
  4. cd /tmp
  5. wget http://cn.php.net/distributions/php-5.2.17.tar.gz
  6. tar xzf php-5.2.17.tar.gz
  7. cd php-5.2.17
  8. ./configure --prefix=/usr/local/php  --enable-fastcgi --enable-force-cgi-redirect --enable-discard-path --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib  --with-curl --enable-ftp  --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf  --enable-mbstring --with-mcrypt --enable-zip  --with-mysql --without-pear
  9. make && make install
  10. cp php.ini-recommended /etc/php.ini

配置apache

1、在/usr/local/ apache/conf/httpd.conf增加如下内容:
  1. NameVirtualHost *:80
  2. <VirtualHost *:80>
  3.   ServerName www.centos.bz
  4.   ServerAlias www.centos.bz centos.bz
  5.   DocumentRoot /var/www/html/
  6.   <IfModule mod_fcgid.c>
  7.     <Directory /var/www/html/>
  8.       Options +ExecCGI
  9.       AllowOverride All
  10.       AddHandler fcgid-script .php
  11.       FCGIWrapper /usr/local/php/bin/php-wrapper .php
  12.       Order allow,deny
  13.       Allow from all
  14.     </Directory>
  15.   </IfModule>
  16.   ServerSignature Off
  17. </VirtualHost>
2、/usr/local/php/bin/php-wrapper内容如下:
  1. #!/bin/sh
  2. # Set desired PHP_FCGI_* environment variables.
  3. # Example:
  4. # PHP FastCGI processes exit after 500 requests by default.
  5. PHP_FCGI_MAX_REQUESTS=10000
  6. export PHP_FCGI_MAX_REQUESTS
  7.  
  8. # Replace with the path to your FastCGI-enabled PHP executable
  9. exec /usr/local/php/bin/php-cgi

启动服务

#启动 mysql
  1. service mysqld start
  2. mysqladmin -uroot password root
  3.  
  4. #启动apache
  5. /usr/local/apache/bin/apachectl -k start
转载请标明文章来源:《 http://www.centos.bz/2012/09/mod_fcgid-run-php-script/》

你可能感兴趣的:(PHP,脚本,mod_fcgid)