Home > Article > Backend Development > PHP How to use PHP-FPM to configure Nginx_PHP tutorial
Nginx, pronounced "Engine-X", is a web server and reverse proxy server. Nginx is well-known for its speed and ability to handle a large number of requests for resources simultaneously and for optimal utilization of resources.
PHP-FPM refers to "PHP FastCGI Process Manager". CGI is an interface standard between external applications (CGI programs) and Web servers. It is a procedure for transferring information between CGI programs and Web servers. It listens on a port just like the web server itself, and passes requests between PHP and the web server. (PS: Nice PHP
Qkuan: 276167802, verification: csl)
Compared with Nginx, Apache is relatively slow when handling a large number of requests. This tutorial provides information on how to install and configure PHP-FPM
Instructions for Nginx, which will help you execute PHP programs on Nginx.
1. Install Nginx
You can choose to install Nginx from source or use the management tool package that comes with the distribution.
Here we only introduce installation using the management tool package.
For example, on Ubuntu you can use apt-get to install nginx as follows:
$ sudo apt-get install nginx
Start the nginx server as follows:
$ sudo service nginx start
Then open http://localhost and see the Nginx welcome interface, which means that our installation is successful.
$ sudo vi /etc/nginx/sites-available/default server { listen 80; 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 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/www; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.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; } }
$ sudo vi /usr/share/nginx/www <?php phpinfo( ); ?>