首页 > 解决方案 > PHP - Docker 中的 LEMP 设置

问题描述

我确实在本地为 PHP 设置了 LEMP 堆栈。但是我遇到了一个问题,当我打开项目浏览器并尝试打开内页时,我仍然可以看到主页内容。

Example: http://mlanding.test/ -> ç†
Example: http://mlanding.test/register -> It still shows me main page content.

nginx 配置示例:

server {
    listen 80;
    server_name mlanding.test;
    index index.php index.html;
    error_log  /var/log/nginx/error.mlanding.log;
    access_log /var/log/nginx/access.mlanding.log;
    root /var/www/mlanding.test;
    
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass php:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }

    location / {
        try_files $uri $uri/ /index.php?$query_string;
        gzip_static on;
    }
}

我怎样才能解决这个重定向?

标签: phpdockerdocker-compose

解决方案


推荐阅读