railon 发表于 2011-12-23 02:53

apache使用php-fpm

<strong>1.安装apache fastcgi模块</strong><br> <span style="font-weight: bold; color: rgb(194, 12, 185);"><font color="#000000">mod_fastcgi下载地址:</font><a href="http://www.fastcgi.com/dist/" target="_blank">http://www.fastcgi.com/dist/</a><br><br>tar</span> <span style="color: rgb(102, 0, 51);">-zxvf</span> mod_fastcgi-current.tar.gz <span style="font-weight: bold; color: rgb(122, 8, 116);"><br>cd</span> mod_fastcgi-2.4.6<br><span style="font-weight: bold; color: rgb(194, 12, 185);">cp</span> Makefile.AP2 Makefile<br><span style="font-weight: bold; color: rgb(194, 12, 185);">make</span> <span style="color: rgb(0, 120, 0);">top_dir</span>=<span style="font-weight: bold; color: rgb(0, 0, 0);">/</span>path<span style="font-weight: bold; color: rgb(0, 0, 0);">/</span>to<span style="font-weight: bold; color: rgb(0, 0, 0);">/</span>apache2<span style="color: rgb(102, 102, 102); font-style: italic;">#你的apache安装路径</span>或者直接编辑Makefile[则不需加top_dir参数]<br><span style="font-weight: bold; color: rgb(194, 12, 185);">make</span> <span style="font-weight: bold; color: rgb(194, 12, 185);">install </span><span style="color: rgb(0, 120, 0);">top_dir</span>=<span style="font-weight: bold; color: rgb(0, 0, 0);">/</span>path<span style="font-weight: bold; color: rgb(0, 0, 0);">/</span>to<span style="font-weight: bold; color: rgb(0, 0, 0);">/</span>apache2<span style="color: rgb(102, 102, 102); font-style: italic;"></span><br><br><strong>2.安装php-fpm<br>在安装PHP-FPM编译的时候会报找不到libevent,可以执行<br>yum -y install libevent*<br>wget http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz<br>tar zxvf </strong><strong><strong>libevent-1.4.12-stable.tar.gz</strong></strong><strong><strong></strong></strong><strong><br>cd libevent-1.4.12<br>./configure --prefix=$prefix <br>mak &amp;&amp; make install<br><br>tar -jxvf php-5.3.3.tar.bz2<br>cd php-5.3.3<br>./configure \<br>--prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc \<br>--with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config \<br>--with-zlib --with-curl --with-jpeg-dir --with-freetype-dir --with-png-dir \<br>--with-libxml-dir=/usr/ </strong><strong><strong>--with-gd </strong></strong><strong> --with-openssl&nbsp; \<br></strong><strong>--with-openssl </strong><strong><strong>--with-ldap</strong></strong> <strong><strong>--with-ldap-sasl --with-xmlrpc --without-pear \</strong></strong><br><strong>--enable-xml --enable-gd-native-ttf \</strong><strong><strong><br></strong></strong><strong>--enable-ctype --enable-calendar --enable-inline-optimization \<br>--enable-magic-quotes --with-bz2 --enable-mbstring \<br>--enable-fpm&nbsp; --enable-safe-mode&nbsp; --enable-bcmath&nbsp; --enable-shmop \<br>--enable-sysvsem --enable-mbregex&nbsp; --enable-mbstring --enable-pcntl&nbsp; \<br></strong><strong><strong>--enable-zip --enable-ftp --enable-sockets --enable-soap </strong></strong><br><strong>--with-libevent-dir=/usr<br>make &amp;&amp; make install<br><br>cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm<br>chmod +x /etc/init.d/php-fpm<br><br>cp -r sapi/fpm/php-fpm.conf /usr/local/etc/</strong><br>配置php-fpm.conf文件中相关参数<br><br><strong><strong>启动php-fpm<br>/etc/init.d/php-fpm start</strong></strong><br><br><br>3.修改apache,让apache支持php-fpm<br>vi httpd.conf<br>add LoadModule fastcgi_module modules/mod_fastcgi.so <br>在vhosts.conf文件的项目中加入以下<br>&nbsp;&nbsp;&nbsp; ScriptAlias /cgi-bin/ "/map/app/php5_poi/bin/"<br>    FastCgiExternalServer /map/app/php5_poi/bin/php-fpm -host 127.0.0.1:9000&nbsp; #<strong>php由外部的fastcgi来处理</strong><br>    AddType application/x-httpd-php .php<br>    AddHandler php5-fastcgi .php<br>    Action php5-fastcgi /cgi-bin/php-fpm<br><font style="background-color: rgb(255, 255, 255);" color="#000000">#</font><span style="background-color: rgb(255, 255, 255);">Action php5-fastcgi <font color="#ff0000"><strong>/cgi-bin/php-fpm</strong></font></span><font style="background-color: rgb(255, 255, 255);" color="#000000"><em>中的<font color="#ff0000"><strong>php-fpm</strong></font>一定要和FastCgiExternalServer中的文件名一样.而且<font color="#ff0000"><strong>/cgi-bin/</strong></font>和前面的ScriptAlias的路径也要一样,两句放一块就是说上面的映射也就是所有的.php文件都由</em></font>/cgi-bin/php-fpm 处理<br><font style="background-color: rgb(255, 255, 255);" color="#000000"><em> 否則會出錯的.</em></font><br> <br>    &lt;Directory "/map/app/php5_poi/bin/"&gt;<br>    Options -Indexes FollowSymLinks +ExecCGI<br>    Order allow,deny<br>    Allow from all<br>    &lt;/Directory&gt;<br>加完以上的,安装完成了。但是php-fpm.conf配置文件需要优化
页: [1]
查看完整版本: apache使用php-fpm