朱纯树博客
VPS测评推荐网站
cloudacead cloudacead

tp5项目 Apache切换nginx环境

tp5 项目在Apache环境下开发并运行正常,切换nginx环境后报404错误。

原因一:在Apache环境中设置了隐藏入口文件index.PHP,而nginx环境下未设置隐藏入口文件,当在nginx环境中时需要在地址栏中加入index.php后才可以访问。

原因二:项目中的入口文件原本是放在public目录下,但是入口文件让我改到了根目录下,在配置nginx.conf文件时需要将根目录地址改一下,如下:

server {
    location /{
        root:'http://www.xxx.com/'
    }
}

解决nginx 下隐藏入口文件问题:在nginx.conf文件中的localtion 下加入下面的代码:

if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php?s=/$1 last;
    break;
}

整体server代码

server {
listen 80;
server_name server_name; #监听地址
    location / {
        root "完整的项目地址";
        index index.html index.htm index.php;
        if (!-e $request_filename) {
            rewrite ^(.*)$ /index.php?s=/$1 last;
            break;
        }
    }
}

文章来源于互联网:tp5项目 Apache切换nginx环境

赞(0) 打赏
未经允许不得转载:VPS测评推荐网站 - 朱纯树博客 » tp5项目 Apache切换nginx环境

评论 3

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #0

    I?ve been exploring for a bit for any high-quality articles or blog posts on this kind of area . Exploring in Yahoo I at last stumbled upon this site. Reading this information So i am happy to convey that I’ve an incredibly good uncanny feeling I discovered exactly what I needed. I most certainly will make certain to do not forget this website and give it a look regularly. ラ ブ ド ー ル

  2. #0

    Clomid commonly increases the level of estrogen in the body, along with testosterone, although usually not to a degree that causes concern brand name cialis online In our study, the monthly cost of combination therapy used in secondary CVD prevention using the cheapest beta blocker, ACEI, statin and cardiac aspirin was 14

    tritymn4周前 (03-01)回复
  3. #0

    Jsososo : http://huenyi.com/

    东南亚小野猫1年前 (2022-01-07)回复