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脚本,并将查询字符串传递给它。

相关推荐
激情的学姐14 小时前
【大型网站技术实践】初级篇:借助Nginx搭建反向代理服务器
运维·nginx
2501_9437823516 小时前
【共创季稿事节】摇骰子:用 ArkTS 实现随机动画与交互反馈
运维·nginx·交互·harmonyos·鸿蒙·鸿蒙系统
AC赳赳老秦17 小时前
防火墙规则批量配置实战:OpenClaw 自动生成模板、批量下发与合规性校验全解析
java·开发语言·人工智能·python·github·php·openclaw
2502_9212860718 小时前
【企业网络管理】DHCP 与 SAMBA:从协议原理到企业级实战配置全解析
开发语言·php
运维管理20 小时前
H3C SecPath W2000-G[AK]系列Web应用防火墙 典型配置举例(E6711 E6712 E6713)-6W108-H3C 官方配置
服务器·网络·php
zlinear数据采集卡1 天前
从协议解析到波形实时显示:硬核拆解ZLinear采集卡上位机软件的开发架构
arm开发·单片机·嵌入式硬件·fpga开发·架构·开源
techdashen1 天前
kTLS 进入 rustls 组织:把 TLS 的数据面交给内核
开发语言·php
Web极客码1 天前
在WordPress Multisite中添加超级管理员用户
服务器·php·网站
漂亮的摩托1 天前
深感一无所长,准备试着从零开始写个富文本编辑器
开发语言·php