前言 * FastCGI是一个程序接口,它能加速公共网关接口(CGI),CGI是一种用最常见的方式使Web服务器调用应用程序的Web应用程序。按一个FastCGI工具来看,用户要求进入一个网站并使用一个专门的应用软件的话,使用FastCGI能够快3到30倍。FastCGI是Web服务器的一种插件。
一、安装apache fastcgi模块:
- 下载地址:http://down.51cto.com/data/139939 (51cto下载中心)
- tar -zxvf mod_fastcgi-current.tar.gz
- cd mod_fastcgi
- cp Makefile.AP2 Makefile
- vi Makefile 修改top_dir=/usr/local/apache2 #你的apache安装路径或者直接编(apache2.0已经安装)
- make
- make install(这里采用apache而不采用nginx的原因是:虽然nginx有很多优点,但是对于大部分中小型网站来说,apache经过优化可以满足访问要求。)
二、安装MYSQL
- tar -zxvf mysql-5.0.75.tar.gz //解压
- cd mysql-5.0.75
- ./configure --prefix=/usr/local/mysql --with-charset=gbk --with-extra-charsets=all
- make
- make install
- groupadd mysql //创建组mysql
- useradd -g mysql mysql //创建mysql用户,把mysql加入到mysql组
- cd /usr/local/mysql/
- cp share/mysql/my-medium.cnf /etc/my.cnf
- cp share/mysql/mysql.server /etc/init.d/mysqld
- (以上是把mysql加入系统服务)
- chown -R mysql.mysql /usr/local/mysql
- /usr/local/mysql/bin/mysql_install_db --user=mysql //初始化数据库
- chown -R mysql.mysql /usr/local/mysql/var
- /usr/local/mysql/bin/mysqld_safe --user=mysql & //启动数据库(或者 service mysqld restart)
三、安装php-fpm
在安装PHP-FPM编译的时候会报找不到libevent,可以执行
- yum -y install libevent*
- wget http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz
- tar zxvf libevent-1.4.12-stable.tar.gz
- cd libevent-1.4.12
- ./configure --prefix=/usr/local/libenent
- mak && make install
- tar -jxvf php-5.3.3.tar.bz2
- cd php-5.3.3
- ./configure \
- --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc \
- --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config \
- --with-zlib --with-curl --with-jpeg-dir --with-freetype-dir --with-png-dir \
- --with-libxml-dir=/usr/ --with-gd --with-openssl \
- --with-openssl --with-ldap --with-ldap-sasl --with-xmlrpc --without-pear \
- --enable-xml --enable-gd-native-ttf \
- --enable-ctype --enable-calendar --enable-inline-optimization \
- --enable-magic-quotes --with-bz2 --enable-mbstring \
- --enable-fpm --enable-safe-mode --enable-bcmath --enable-shmop \
- --enable-sysvsem --enable-mbregex --enable-mbstring --enable-pcntl \
- --enable-zip --enable-ftp --enable-sockets --enable-soap --with-libevent-dir=/usr/local/libevent/
- make && make install
- cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
- chmod +x /etc/init.d/php-fpm
- cp -r sapi/fpm/php-fpm.conf /usr/local/php5/etc/
启动php-fpm
/etc/init.d/php-fpm start
此时启动应该会报错,说php-fpm.conf配置文件中很多选项没有打开,只要按照它的提示打开就OK。
