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

相关推荐
YUJIANYUE8 小时前
PHP纹路验证码
开发语言·php
Harvey90310 小时前
通过 Helm 部署 Nginx 应用的完整标准化步骤
linux·运维·nginx·k8s
MZ_ZXD00110 小时前
springboot旅游信息管理系统-计算机毕业设计源码21675
java·c++·vue.js·spring boot·python·django·php
JMchen12312 小时前
Android后台服务与网络保活:WorkManager的实战应用
android·java·网络·kotlin·php·android-studio
AZ996ZA15 小时前
自学linux的第二十一天【DHCP 服务从入门到实战】
linux·运维·服务器·php
darkb1rd17 小时前
八、PHP SAPI与运行环境差异
开发语言·网络安全·php·webshell
陌上花开缓缓归以17 小时前
LiteOS和RTOS 系统选型分析
arm开发
darkb1rd17 小时前
七、PHP配置(php.ini)安全最佳实践
安全·php·webshell
全栈工程师修炼指南17 小时前
Nginx | stream content 阶段:UDP 协议四层反向代理浅析与实践
运维·网络·网络协议·nginx·udp
JSON_L18 小时前
Fastadmin中使用GatewayClient
php·fastadmin