dnmp运行时404报错

dnmp运行时404报错

问题截图:

dnmp简介

M1芯片(Arm CPU) 环境中搭建PHP+NGINX+MYSQL的利器,docker容器管理当前使用的软件,可以简单安装软件和扩展。

localhost.conf 原始文件如下:

shell 复制代码
server {
    listen       80;
    server_name  xx.com;
    root   /www/xx/web;
    index  index.php index.html index.htm;
    #charset koi8-r;

    access_log /dev/null;
    #access_log  /var/log/nginx/nginx.localhost.access.log  main;
    error_log  /var/log/nginx/nginx.localhost.error.log  warn;

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
    
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ [^/]\.php(/|$) {
        fastcgi_pass   php56:9000;
        include        fastcgi-php.conf;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

添加如下代码片段:

powershell 复制代码
location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

上述位置块使用try_files指令来查找与请求中的URI匹配的文件,如果该文件不存在,则通过向URI添加'/'并尝试在其后查找一个目录来实现。最后,如果前两个过程都失败了,则Nginx将发起一个内部重定向到URI包含的PHP脚本,并将查询字符串传递给它。

相关推荐
洋葱 ☠4 分钟前
极简部署linux免费ssl证书Let‘s Encrypt,自动续签,nginx/apache都可以,域名指向服务器即可,无需项目
linux·nginx·ssl
KeLin&1 小时前
讯为iTOP4412-Qt5.7环境搭建
开发语言·arm开发·qt·arm
shenghuiping20011 小时前
OPSWAT https enable 问题解决
nginx·https·ssl·443·opswat
m0_738120721 小时前
应急响应——知攻善防蓝队溯源靶机Linux-2详细流程
linux·服务器·网络·安全·web安全·php
oMcLin1 小时前
如何在Ubuntu 22.04上通过调优Nginx和PHP‑FPM,提升高并发WordPress网站的负载均衡与缓存性能?
nginx·ubuntu·php
全栈小51 小时前
【PHP】如何将ThinkPHP 5部署到windows服务器的IIS里,和PHP版本又是一个怎么样的关系,三分钟教程搞定部署
服务器·windows·php
JaguarJack1 小时前
2026 年 PHP 8.4 依然重要:跳到 8.5 之前你该掌握的特性
后端·php·服务端
BingoGo1 小时前
2026 年 PHP 8.4 依然重要:跳到 8.5 之前你该掌握的特性
后端·php
五仁火烧16 小时前
Vue3 项目的默认端口行为
服务器·vue.js·nginx·容器·vue
专注前端30年17 小时前
【PHP开发与安全防护实战】性能调优手册
android·安全·php