> /etc/portage/package.useemerge -av dev-lang/php配置很简单,我本机版本是 php5.4,那么编辑文件 /etc/php/fpm-php5.4">
当前位置:Gxlcms > PHP教程 > Gentoo中配置以FastCGI方式运行php

Gentoo中配置以FastCGI方式运行php

时间:2021-07-01 10:21:17 帮助过:19人阅读

  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"

人气教程排行