PHP How to use PHP-FPM configuration nginx_php Tutorial

Source: Internet
Author: User
Tags nginx server
Nginx reads "Engine-x", which is a Web server and a reverse proxy server. Nginx is a household name because of its speed and ability to handle large volumes of resource requests and the best use of resources.


PHP-FPM refers to the "PHP fastcgi process Manager". CGI is an interface standard between an external application (CGI program) and a Web server, and is a discipline for passing information between CGI programs and Web servers. It listens to a port just like the Web server itself, and through PHPand a request between the Web server. (Ps:t good PHPQ-Buckle 峮: 276167802, verify: CSL)


Compared with Nginx, ApacheIt is relatively slow to handle a large number of requests. This tutorial provides instructions on how to install and configure PHP-FPM Nginx, which will help you execute PHP programs on Nginx.


1. Installing Nginx


You can choose to install Nginx from the source code, or you can use the Administration Kit with the release version.


Here we only describe the installation using the Administration Kit.


For example, you can use Apt-get to install Nginx on Ubuntu as shown below:


$ sudo apt-get install Nginx


Start the Nginx server as follows:


$ sudo service nginx start


Then open the http://localhost and see the Nginx welcome interface to show that we have successfully installed.



2. Installing PHP5-FPM


Next, install PHP5-FPM using the Administration Kit.


For example, you can use Apt-get to install PHP5-FPM in Ubuntu. As shown below:


$ sudo apt-get install PHP5-FPM



3. Add PHP configuration to Nginx


Next, locate/Etc/nginx/sites-available/default the file, and add the following line:


$ sudo vi/etc/nginx/sites-available/defaultserver {listen   ; root/usr/share/nginx/www; index index.php Index.html index.htm; server_name example.com; Location/{   try_files $uri $uri//index.html;} error_page 404/404.html; error_page 502 503 504/50x.html; locat Ion =/50x.html {   root/usr/share/nginx/www;} # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 lo cation ~ \.php$ {   try_files $uri =404;   Fastcgi_pass Unix:/var/run/php5-fpm.sock;   Fastcgi_index index.php;   Fastcgi_param script_filename $document _root$fastcgi_script_name;   Include Fastcgi_params; }}



4. Setting the listening parameters in PHP5-FPM www.conf


Next, we need to make the following changes to the php-frpm configuration.


By default, you will see the following listening entry in the www.conf file:


$ sudo vi/etc/php5/fpm/pool.d/www.conf


Listen = 127.0.0.1:9000


Replace the above listener with the following, other intact:


$ sudo vi/etc/php5/fpm/pool.d/www.conf


Listen =/var/run/php5-fpm.sock




5. Restart Nginx and PHP5-FPM


Restart PHP5-FPM and Nginx. As shown below:


$ sudo service nginx restart



$ sudo service php5-fpm restart


Then create the index.php file in the Nginx root directory and run the test:


$ sudo vi/usr/share/nginx/www
 
  


Finally, open the browser and enter http://localhost/index.php to display PHPRelated information.

http://www.bkjia.com/PHPjc/635062.html www.bkjia.com true http://www.bkjia.com/PHPjc/635062.html techarticle Nginx reads "Engine-x", which is a Web server and a reverse proxy server. Nginx is a household name because of its speed and ability to handle large volumes of resource requests and the best use of resources. ...

  • Related Article

    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.