Nginx and FastCGI Integration

Source: Internet
Author: User

Install nginx + FastCGI


Nginx installation:


# Nginx-1.4.2.tar.gz

# Libevent-1.4.13-stable.tar.gz

Yum install PCRE-devel OpenSSL-devel


CD/usr/local/src

Tar zxvf nginx-1.4.2.tar.gz

CD nginx-1.4.2

. /Configure -- prefix =/usr/local/nginx -- sbin-Path =/usr/sbin/nginx -- conf-Path =/etc/nginx. conf -- error-log-Path =/var/log/nginx/error. log -- http-log-Path =/var/log/nginx/access. log -- PID-Path =/var/run/nginx. PID -- user = nginx -- group = nginx -- with-http_ssl_module -- with-http_flv_module -- with-http_gzip_static_module -- with-http_stub_status_module -- with-http_gunzip_module -- with-http_perl_module -- http-client-body-temp-Path =/var/tmp/nginx/client /-- http-proxy-temp-Path =/var/tmp/nginx/Proxy/-- http-FastCGI-temp-Path =/var/tmp/nginx/fcgi/-- http- uwsgi-temp-Path =/var/tmp/nginx/uwsgi -- http-scgi-temp-Path =/var/tmp/nginx/scgi -- With-PCRE

Make

Make install


######################################## #############################

FastCGI Installation

Yum install libxml2-devel OpenSSL-devel bzip2-devel

CD/usr/local/src

Tar zxvf php-5.4.13.tar.gz

CD/usr/local/src/php-5.4.13

. /Configure -- prefix =/usr/local/PHP -- enable-FPM -- With-OpenSSL -- enable-mbstring -- enable-sysvshm -- With-config-file-Path =/etc -- -config-file-scan-Dir =/etc/PHP. D -- with-bz2 -- With-curl -- enable-sockets -- With-FreeType-dir -- With-JPEG-dir -- With-PNG-dir -- With-zlib-dir -- With-libxml- dir =/usr -- enable-XML

-- With-mysql -- With-mysqli

Make

Make Test

Make install

# Provide a configuration file for PHP:

# Cp PHP. ini-production/etc/PHP. ini


# Provide the sysv init script for PHP-FPM and add it to the service list:

# Cp SAPI/FPM/init. d. php-FPM/etc/rc. d/init. d/PHP-FPM

# Chmod + x/etc/rc. d/init. d/PHP-FPM

# Chkconfig -- add PHP-FPM

# Chkconfig PHP-FPM on


Provide configuration files for PHP-FPM:

# Cp/usr/local/PHP/etc/php-fpm.conf.default/usr/local/PHP/etc/php-fpm.conf


Edit the configuration file of PHP-FPM:

# Vim/usr/local/PHP/etc/php-fpm.conf

Configure FPM related options for your required values and enable the PID file (the last line below ):

PM. max_children = 150

PM. start_servers = 8

PM. min_spare_servers = 5

PM. max_spare_servers = 10

PID =/usr/local/PHP/var/run/php-fpm.pid


Next we can start PHP-FPM:

# Service PHP-FPM start


Run the following command to verify the running status (if the command output contains several PHP-FPM processes, the startup is successful ):

# Ps aux | grep PHP-FPM


######################################## ##############

Nginx and PHP-FPM Configuration


PHP configuration:

1. VI php-fpm.conf

Listen_address 192.168.2.22: 9000;

User nobody; remove comments

Group nobody; remove comments

2. allow_clients 192.168.2.22


3. request_terminate_timeout = 0 remove comments


Nginx Configuration:


Unchanged: # location ~ \. Php $ {

# Root HTML;

# Fastcgi_pass 127.0.0.1: 9000;

# Fastcgi_index index. php;

# Fastcgi_param script_filename/scripts $ fastcgi_script_name;

# Include fastcgi_params;

#}

Changed:

Fastcgi_pass 192.168.2.22: 9000;

Fastcgi_param cript_filename $ document_root $ fastcgi_script_name;


Conclusion: listen_address 192.168.2.22: 9000; | 127.0.0.1: 9000

Allow_clients 192.168.2.22; | 127.0.0.1

Fastcgi_pass 192.168.2.22: 9000; | 127.0.0.1: 9000

 

The values of these three parameters must be the same


This article is from the "frequently used document" blog. For more information, contact the author!

Nginx and FastCGI Integration

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.