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();

?>

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM