Ubuntu14.04 Configuration Nginx and PHP-FPM

Source: Internet
Author: User
Tags fpm install php php source code phpinfo what php

1, what is CGI?

The CGI full name is the "Public Gateway Interface" (Common Gateway Interface), a tool that HTTP servers "talk" to programs on your or other machines, and their programs must run on a network server.

2, what is fastcgi?

FastCGI is like a resident (long-live) CGI, which can be executed all the time, and it won't take a while to fork once (this is CGI's most criticized Fork-and-execute model).
It also supports distributed operations, where the FastCGI program can execute on a host other than the Web server and accept requests from other Web servers.

3, what php-cgi?

PHP-CGI is the fastcgi Manager with PHP.

4, what is PHP-FPM?

PHP-FPM is a PHP fastcgi manager that is used only in PHP. PHP-FPM is actually a patch of PHP source code, designed to integrate FASTCGI process management into the PHP package.
PHP5.3.3 version has been integrated PHP-FPM, no longer a third party package. PHP-FPM provides a better way to manage PHP processes, can effectively control memory and process, can smooth overload PHP configuration,
so the official PHP included. /configure with--ENABLE-FPM parameters to open the PHP-FPM. Use PHP-FPM to control the php-cgi fastcgi process.

5, install php-fpm?

Apt-get Install PHP5-FPM

6, configure Nginx and PHP-FPM

Configure/ect/nginx/nginx.conf

user www-data; worker_processes 8; timer
_resolution 100ms;
Worker_rlimit_nofile 20240;

worker_priority-5;
Error_log/var/log/nginx/error.log;

Pid/var/run/nginx.pid;
    Events {Worker_connections 2048;
    Use Epoll;
# multi_accept on;

    } http {include/etc/nginx/mime.types;

    Access_log/var/log/nginx/access.log;
    Sendfile on;

    Tcp_nopush on;
    #keepalive_timeout 0;
    Keepalive_timeout 65;

    Tcp_nodelay on;
    gzip on;
    Gzip_min_length 1100;
    Gzip_buffers 8k;
    Gzip_comp_level 3;
    Gzip_http_version 1.1;
    Gzip_proxied any;
    Gzip_types text/plain application/xml application/x-javascript text/css; Gzip_disable "MSIE [1-6]\. (?!.

    *SV1) ";
include/etc/nginx/conf.d/*.conf;

    # include/etc/nginx/sites-enabled/*;
    Client_max_body_size 100M;
Server_tokens off; }

Configure/ect/nginx/conf.d/default.conf

 server {Listen 80;

    server_name bishe.xy.com;
    CharSet UTF-8;

    #access_log/var/log/nginx/log/host.access.log Main;
        Location/{root/www/bishe.xy.com;
    Index index.html index.htm index.php;

    } error_page 404/404.html;
    # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html;
    Location =/50x.html {#nginx The default www root file as follows, which can be modified for its own specified directory root/www; # Proxy The PHP scripts to Apache listening on 127.0.0.1:80 # location ~ \.php$ {# proxy_p
    Ass http://127.0.0.1; # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ {R
    	oot/www/bishe.xy.com;
        Fastcgi_pass Unix:/var/run/php5-fpm.sock;
        Fastcgi_index index.php;
        Fastcgi_param script_filename $document _root$fastcgi_script_name; Include Fastcgi_paraMs # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' One # location ~/\.
    HT {deny all; } server {    listen       80;   }    #        proxy_ Pass   http://127.0.0.1;                          &N Bsp                                   &NB Sp                                   &NB Sp                            1,1        
   Top

As configured, after completion, create a phpinfo.php file in the/www/bishe.xy.com directory, which reads as follows:

<?php phpinfo ();?>

Now you need to configure the/etc/hosts file and add the following:

127.0.0.1 bishe.xy.com

Enter the following in the address bar of the browser:

bishe.xy.com/phpinfo.php

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.