Configure to run php in FastCGI mode in Gentoo
- Echo "dev-lang/php fpm">/etc/portage/package. use
- Emerge-av dev-lang/php
Configuration is very simple, my local version is php5.4, then edit the file/etc/php/fpm-php5.4/php-fpm.conf, modify listen address
- ; Listen = 127.0.0.1: 9000
- Listen =/var/run/php-fpm.sock
Nginx Enable fastcgi USE flag
- Echo "www-servers/nginx fastcgi">/etc/portage/package. use
- Emerge-av www-servers/nginx
Edit/etc/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 Open the php USE flag
- Echo "www-servers/lighttpd php">/etc/portage/package. use
- Emerge-av www-servers/lighttpd
Edit/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 First install www-apache/mod_fastcgi_handler
- Emerge-av
www-apache/mod_fastcgi_handler
At the same time, PHP needs to enable the apache2 USE mark
- Echo "dev-lang/php apache2">/etc/portage/package. use
- Emerge-av dev-lang/php
Edit the/etc/apache2/modules. d/70_mod_php5.conf file and tell apache2, php-fpm sock path
-
- # AddHandler application/x-httpd-php. php. php5. phtml
- # AddHandler application/x-httpd-php-source. phps
- AddHandler fcgi:/var/run/php-fpm.sock. php. php5
Edit the/etc/apache2/modules. d/20_mod_fastcgi_handler.conf file
-
- LoadModule fastcgi_handler_module modules/mod_fastcgi_handler.so
Edit the/etc/conf. d/apache2 file, add-D FASTCGI_HANDLER after-D php5, and tell apache2 to start in fastcgi-handler mode, similar to the following configuration:
- APACHE2_OPTS = "-D DEFAULT_VHOST-d info-d ssl-D SSL_DEFAULT_VHOST-d language-D PHP5-D FASTCGI_HANDLER"
|