lnmp環境的nginx的tp5配置

  php7.1php

 1 server {
 2   listen 80;
 3   server_name www.tp5.com;
 4   access_log  /home/wwwroot/access.log  combined;
 5   error_log /home/wwwroot/error.log;
 6 
 7   set $root /home/wwwroot/default/mytp5/tp5/public;
 8 
 9   location ~ \.php {
10         fastcgi_pass unix:/tmp/php-cgi.sock;
11         fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
12         fastcgi_param PATH_INFO $fastcgi_path_info;
13         fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
14         fastcgi_param    SCRIPT_FILENAME    $root$fastcgi_script_name;
15         include        fastcgi_params;
16     }
17     location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$
18     {
19         root $root;
20     }
21     location / {
22         root    $root;
23         index    index.html index.php;
24         if ( -f $request_filename) {
25             break;
26         }
27         if ( !-e $request_filename) {
28             rewrite ^(.*)$ /index.php/$1 last;
29             break;
30         }
31     }
32 
33 
34 }

若是出現了錯誤css

 

1 FastCGI sent in stderr: "Access to the script '/usr/local/nginx/html' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 192.168.124.1, server: www.tp5.com, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/php-cgi.sock:", host: "www.tp5.com"

  1. 在你php-fpm配置文件php-fpm.conf中設置security.limit_extensions 爲 .php 或 .php5,或者其餘任何與你環境一致的後綴名。 對於開發環境下的一些用戶來講, 徹底移除全部security.limit_extensions的值或設置爲FALSE,可以保證能夠正常工做.

     

  2. 在你的nginx配置文件中設置fastcgi_pass 爲你的socket地址(e.g. unix:/var/run/php-fpm/php-fpm.sock;), 替代ip地址:端口這種方式(127.0.0.1:9000).

     

  3. 檢查你的SCRIPT_FILENAMEfastcgi_param 並根據你文件的地址來設置它們.html

  4. 在你的nginx配置文件中包含有fastcgi_split_path_info ^(.+\.php)(/.+)$; 則全部其餘的對應fastcgi參數也都應該在location塊中定義;具體可參考phalcon的nginx官方配置nginx

  5. 在你的php.ini配置文件中,設置cgi.fix_pathinfo=1php7

我就是由於第五個緣由,cgi.fix_pathinfo默認沒有設置爲1,而形成頁面老是顯示Access deniedsocket

相關文章
相關標籤/搜索