免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3995 | 回复: 0
打印 上一主题 下一主题

apache使用php-fpm [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-23 02:53 |只看该作者 |倒序浏览
1.安装apache fastcgi模块
mod_fastcgi下载地址:http://www.fastcgi.com/dist/

tar
-zxvf mod_fastcgi-current.tar.gz
cd
mod_fastcgi-2.4.6
cp Makefile.AP2 Makefile
make top_dir=/path/to/apache2 #你的apache安装路径或者直接编辑Makefile[则不需加top_dir参数]
make install top_dir=/path/to/apache2

2.安装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=$prefix
mak && make install

tar -jxvf php-5.3.3.tar.bz2
cd php-5.3.3
./configure \
--prefix=/usr/local/php --with-config-file-path=/usr/local/php/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
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/etc/

配置php-fpm.conf文件中相关参数

启动php-fpm
/etc/init.d/php-fpm start



3.修改apache,让apache支持php-fpm
vi httpd.conf
add LoadModule fastcgi_module modules/mod_fastcgi.so
在vhosts.conf文件的项目中加入以下
    ScriptAlias /cgi-bin/ "/map/app/php5_poi/bin/"
FastCgiExternalServer /map/app/php5_poi/bin/php-fpm -host 127.0.0.1:9000  #php由外部的fastcgi来处理
AddType application/x-httpd-php .php
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php-fpm
#Action php5-fastcgi /cgi-bin/php-fpm中的php-fpm一定要和FastCgiExternalServer中的文件名一样.而且/cgi-bin/和前面的ScriptAlias的路径也要一样,两句放一块就是说上面的映射也就是所有的.php文件都由/cgi-bin/php-fpm 处理
否則會出錯的.

<Directory "/map/app/php5_poi/bin/">
Options -Indexes FollowSymLinks +ExecCGI
Order allow,deny
Allow from all
</Directory>
加完以上的,安装完成了。但是php-fpm.conf配置文件需要优化
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP