Home  >  Article  >  Backend Development  >  Configure nginx to support php

Configure nginx to support php

不言
不言Original
2018-05-07 10:05:041465browse

This article mainly introduces the configuration of nginx to support php, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

 server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/host.access.log  main;
        location / {
            root   html;
            index 
 index.php
 index.html index.htm;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
     
   location ~ \.php$ {
                root           html;
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }

The code must be written in the server

Save and restart nginx

Restart php service php-fpm restart

Related recommendations:

Configure nginx php mysql to start automatically

The above is the detailed content of Configure nginx to support php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn