windows服务器宝塔 nginx+th5.0 配置,404 找不到文件解决

时间 17 : 22 , Jun 18,2020

今天把thinkphp5.0 项目,从apache服务器转移到nginx服务器。

转以后报404错误。

一开始的nginx配置文件

server 
{
    listen 8080;
    server_name 127.0.0.1;
    index index.php index.html index.htm default.php default.htm default.html;
    root E:/wwwroot/fyjsxy/public;
		
	#START-ERROR-PAGE
	#error_page 403 /403.html;
	error_page 404 /404.html;
    #error_page 502 /502.html;
	#END-ERROR-PAGE
    
    #HTTP_TO_HTTPS_START
    #HTTP_TO_HTTPS_END

    #LIMIT_INFO_START
    #LIMIT_INFO_END

    #SSL-INFO-START
    #SSL-INFO-END
        
    #反代清理缓存配置
    location ~ /purge(/.*) {
        proxy_cache_purge cache_one $1$is_args$args;
    }
   
    #proxy 反向代理
    include proxy/127.0.0.1/*.conf;

    #PHP-INFO-START 
    include php/56.conf;
    #PHP-INFO-END
    
    #REWRITE-START
    include rewrite/127.0.0.1/*.conf;
    #REWRITE-END

    #redirect 重定向
    include redirect/127.0.0.1/*.conf;

    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }
    
    #一键申请SSL证书验证目录相关设置
    location ~ \.well-known{
        allow all;
    }

    access_log  E:/BtSoft/wwwlogs/127.0.0.1.log;
    error_log  E:/BtSoft/wwwlogs/127.0.0.1.error.log;
}

然后添加了###框里面的

server 
{
    listen 8080;
    server_name 127.0.0.1;
    index index.php index.html index.htm default.php default.htm default.html;
    root E:/wwwroot/fyjsxy/public;
		
	#START-ERROR-PAGE
	#error_page 403 /403.html;
	error_page 404 /404.html;
    #error_page 502 /502.html;
	#END-ERROR-PAGE
    
    #HTTP_TO_HTTPS_START
    #HTTP_TO_HTTPS_END

    #LIMIT_INFO_START
    #LIMIT_INFO_END

    #SSL-INFO-START
    #SSL-INFO-END
        
    #反代清理缓存配置
    location ~ /purge(/.*) {
        proxy_cache_purge cache_one $1$is_args$args;
    }
    
 ##########################################################################
    location ~ \.php/ {
       if ($request_uri ~ ^(.+\.php)(/.+?)($|\?)) { }
       fastcgi_pass 127.0.0.1:9000;
       include fastcgi_params;
       fastcgi_param SCRIPT_NAME     $1;
       fastcgi_param PATH_INFO       $2;
       fastcgi_param SCRIPT_FILENAME $document_root$1;
    }
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
 ############################################################################  
    #proxy 反向代理
    include proxy/127.0.0.1/*.conf;



    #PHP-INFO-START 
    include php/56.conf;
    #PHP-INFO-END
    
    #REWRITE-START
    include rewrite/127.0.0.1/*.conf;
    #REWRITE-END

    #redirect 重定向
    include redirect/127.0.0.1/*.conf;

    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }
    
    #一键申请SSL证书验证目录相关设置
    location ~ \.well-known{
        allow all;
    }

    access_log  E:/BtSoft/wwwlogs/127.0.0.1.log;
    error_log  E:/BtSoft/wwwlogs/127.0.0.1.error.log;
}

然后发现运行不了,查看nginx 错误日志出现错误   设置的      fastcgi_pass 127.0.0.1:9000 这个地方没有开启。

然后查了下百度,开启如下图!


image.png

留 言

  

网站简介

作者的个人博客,记事本,记录工作和学习中遇到的问题和一些基础功能开发!
好好学习,天天向上!

常用网站

Copyright © 2016-2024 LXC.All rights reserved. 皖ICP备2023025580号-1