Configure to run php in FastCGI mode in Gentoo

Source: Internet
Author: User
Configure to run php in FastCGI mode in Gentoo

  1. Echo "dev-lang/php fpm">/etc/portage/package. use
  2. 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

  1. ; Listen = 127.0.0.1: 9000
  2. Listen =/var/run/php-fpm.sock

Nginx

Enable fastcgi USE flag

  1. Echo "www-servers/nginx fastcgi">/etc/portage/package. use
  2. Emerge-av www-servers/nginx

Edit/etc/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

Open the php USE flag

  1. Echo "www-servers/lighttpd php">/etc/portage/package. use
  2. Emerge-av www-servers/lighttpd

Edit/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

First install www-apache/mod_fastcgi_handler

  1. Emerge-avwww-apache/mod_fastcgi_handler

At the same time, PHP needs to enable the apache2 USE mark

  1. Echo "dev-lang/php apache2">/etc/portage/package. use
  2. Emerge-av dev-lang/php

Edit the/etc/apache2/modules. d/70_mod_php5.conf file and tell apache2, php-fpm sock path

  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

Edit the/etc/apache2/modules. d/20_mod_fastcgi_handler.conf file

  1. 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:

  1. APACHE2_OPTS = "-D DEFAULT_VHOST-d info-d ssl-D SSL_DEFAULT_VHOST-d language-D PHP5-D FASTCGI_HANDLER"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.