>백엔드 개발 >PHP 튜토리얼 >FastCGI 모드에서 PHP를 실행하도록 젠투 구성하기

FastCGI 모드에서 PHP를 실행하도록 젠투 구성하기

WBOY
WBOY원래의
2016-07-25 09:07:321089검색
  1. echo "dev-lang/php fpm" >> /etc/portage/package.use
  2. emerge -av dev-lang/php
复制代码

配置很简单,我本机版本是 php5.4,那么编辑文件 /etc/php/fpm-php5.4/php-fpm.conf,修改 listen address

  1. ;listen = 127.0.0.1:9000
  2. listen = /var/run/php-fpm.sock
复制代码

nginx

打开 fastcgi USE 标记

  1. echo "www-servers/nginx fastcgi" >> /etc/portage/package.use
  2. emerge -av www-servers/nginx
复制代码

编辑 /etc/nginx/nginx.conf

  1. location ~ .*.php$ {
  2. fastcgi_pass unix:/var/run/php-fpm.sock;
  3. fastcgi_index index.php;
  4. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  5. include fastcgi_params;
  6. }
复制代码

lighttpd

打开 php USE 标记

  1. echo "www-servers/lighttpd php" >> /etc/portage/package.use
  2. emerge -av www-servers/lighttpd
复制代码

编辑 /etc/lighttpd/mod_fastcgi.conf

  1. server.modules = ("mod_fastcgi")
  2. fastcgi.server = ( ".php" =>
  3. ( "localhost" =>
  4. (
  5. "socket" => "/var/run/php-fpm.sock",
  6. )
  7. )
  8. )
  9. fastcgi.map-extensions = ( ".php3" => ".php", ".php4" => ".php", ".php5" => ".php" )
复制代码

apache

首先需安装 www-apache/mod_fastcgi_handler

  1. emerge -av www-apache/mod_fastcgi_handler
复制代码

同时 PHP 需要打开 apache2 USE 标记

  1. echo "dev-lang/php apache2" >> /etc/portage/package.use
  2. emerge -av dev-lang/php
复制代码

编辑文件 /etc/apache2/modules.d/70_mod_php5.conf,告诉 apache2,php-fpm sock 的路径

  1. # AddHandler application/x-httpd-php .php .php5 .phtml
  2. # AddHandler application/x-httpd-php-source .phps
  3. AddHandler fcgi:/var/run/php-fpm.sock .php .php5
复制代码

编辑文件 /etc/apache2/modules.d/20_mod_fastcgi_handler.conf

  1. LoadModule fastcgi_handler_module modules/mod_fastcgi_handler.so
复制代码

编辑文件 /etc/conf.d/apache2,在 -D php5 后面添加 -D FASTCGI_HANDLER,告诉 apache2 以 fastcgi-handler 模式启动,类似如下的配置:

  1. APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5 -D FASTCGI_HANDLER"
复制代码


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.