-
- echo "dev-lang/php fpm" >> /etc/portage/package.use
- emerge -av dev-lang/php
复制代码
配置很简单,我本机版本是 php5.4,那么编辑文件 /etc/php/fpm-php5.4/php-fpm.conf,修改 listen address
-
- ;listen = 127.0.0.1:9000
- listen = /var/run/php-fpm.sock
复制代码
nginx
打开 fastcgi USE 标记
-
- echo "www-servers/nginx fastcgi" >> /etc/portage/package.use
- emerge -av www-servers/nginx
复制代码
编辑 /etc/nginx/nginx.conf
-
- location ~ .*.php$ {
- fastcgi_pass unix:/var/run/php-fpm.sock;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- }
复制代码
lighttpd
打开 php USE 标记
-
- echo "www-servers/lighttpd php" >> /etc/portage/package.use
- emerge -av www-servers/lighttpd
复制代码
编辑 /etc/lighttpd/mod_fastcgi.conf
-
- server.modules = ("mod_fastcgi")
- fastcgi.server = ( ".php" =>
- ( "localhost" =>
- (
- "socket" => "/var/run/php-fpm.sock",
- )
- )
- )
- fastcgi.map-extensions = ( ".php3" => ".php", ".php4" => ".php", ".php5" => ".php" )
复制代码
apache
首先需安装 www-apache/mod_fastcgi_handler
-
- emerge -av
www-apache/mod_fastcgi_handler
复制代码
同时 PHP 需要打开 apache2 USE 标记
-
- echo "dev-lang/php apache2" >> /etc/portage/package.use
- emerge -av dev-lang/php
复制代码
编辑文件 /etc/apache2/modules.d/70_mod_php5.conf,告诉 apache2,php-fpm sock 的路径
-
- # AddHandler application/x-httpd-php .php .php5 .phtml
- # AddHandler application/x-httpd-php-source .phps
- AddHandler fcgi:/var/run/php-fpm.sock .php .php5
复制代码
编辑文件 /etc/apache2/modules.d/20_mod_fastcgi_handler.conf
-
- LoadModule fastcgi_handler_module modules/mod_fastcgi_handler.so
复制代码
编辑文件 /etc/conf.d/apache2,在 -D php5 后面添加 -D FASTCGI_HANDLER,告诉 apache2 以 fastcgi-handler 模式启动,类似如下的配置:
-
- APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP5 -D FASTCGI_HANDLER"
复制代码
|