Nginx配置直接php

nginx配置文件:

server {
    listen       80;
    server_name  localhost;

    access_log  /var/log/nginx/log/host.access.log  main;
    root   /usr/share/nginx/html;  #原本这个设置是在下面localtion里面的

    location / {
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~* \.php$ {
        fastcgi_index   index.php;
        fastcgi_pass    127.0.0.1:9000;
        include         fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;  
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }
}

php-fpm配置文件(注意:可能有些php版本不是这个文件,但只要意思到位即可):

vi /etc/php-fpm.d/www.conf

修改这两个地方为nginx用户

最后测试php页面:

<?php

phpinfo();

?>

 

 

posted @ 2018-09-09 21:06  EasonJim  阅读(1164)  评论(0编辑  收藏  举报