php +nginx 安装完程序报404 错误解决方法

作者: admin 分类: Error 发布时间: 2019-03-17 21:10 浏览:1,045 次    

原因:

nginx 默认是不支持 PATHINFO 模式

解决方法

 修改nginx配置文件nginx.conf,如果是虚拟主机请修改相应配置文件

user nginx;
worker_processes 1;
error_log logs/error.log;

http {
 include mime.types;
 default_type application/octet-stream;

      server {
      listen 80; 
      root /usr/local/nginx/html;
      index index.html index.htm index.php;
      server_name _;
           location / { 
           try_files $uri $uri/ =404;
           } 
           location ~ \.php(.*)$ {
           include fastcgi_params;
           fastcgi_index index.php;
           fastcgi_pass unix:/run/php/php7.0-fpm.sock;
           fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_path_info;
           fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
           } 
        }
}

温馨提示:如无特殊说明,本站文章均为作者原创,转载时请注明出处及相应链接!

发表评论