apache22 + mod_fastcgi + php-fpm

安裝apache22

#cd /usr/ports/www/apache22
#make WITH_MPM=worker install clean

安裝php5

#cd /usr/ports/lang/php5
#make install clean ( 記得勾FPM )

安裝fastcgi

#cd /usr/ports/www/mod_fastcgi
#make install clean

修改apache設定

#vim /usr/local/etc/apache22/httpd.conf
LoadModule fastcgi_module     libexec/apache22/mod_fastcgi.so
Include etc/apache22/extra/httpd-mpm.conf

#vim /usr/local/etc/apache22/Includes/php.conf
<IfModule prefork.c>
  LoadModule php5_module        libexec/apache22/libphp5.so
  AddType application/x-httpd-php .php .html
  AddType application/x-httpd-php-source .phps
</IfModule>

<IfModule worker.c>
  FastCGIExternalServer /usr/local/sbin/php-fpm -socket /tmp/php-fpm.sock
  AddHandler php-fastcgi .php
  Action php-fastcgi /usr/local/sbin/php-fpm.fcgi
  ScriptAlias /usr/local/sbin/php-fpm.fcgi /usr/local/sbin/php-fpm
  <Directory /usr/local/sbin >
    Options ExecCGI FollowSymLinks
    SetHandler fastcgi-script
    Order allow,deny
    Allow from all
  </Directory>
</IfModule>

DirectoryIndex index.php index.html

修改php-fpm.conf

#vim /usr/local/etc/php-fpm.conf
#listen = 127.0.0.1:9000
listen = /tmp/php-fpm.sock

啟動php-fpm, apache22

#vim /etc/rc.conf
##fpm
php_fpm_enable="YES"

##apache
apache22_enable="YES"

#/usr/local/etc/rc.d/php-fpm start
#/usr/local/etc/rc.d/apache22 start

ref.

Apache + mod_fastcgi + php-fpm 設定

發佈留言

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料