【问题标题】:SSL's phpMyAdmin page 404 Not Found [Nginx + Centos7.5]SSL 的 phpMyAdmin 页面 404 Not Found [Nginx + Centos7.5]
【发布时间】:2021-07-25 22:01:15
【问题描述】:

我正在学习 Nginx。我想问一下带有 SSL 的 phpMyAdmin。 我用 2 个静态域做了 Cerbot SSL。我可以访问 phpMyAdmin。 作为http://mywebiste.com/phpMyAdmin/ 但是当我打开https://mywebiste.com/phpMyAdmin/ 错误说

404 未找到。

我一直在搜索错误日志。但我仍然不知道如何在 pma 设置日志,所以我看不到它。 请教我写设置代码好吗?

这是我当前的设置文件。

vi /etc/nginx/conf.d/phpmyadmin.conf

server {
       #listen 80;
    listen 443 ssl;
    ssl_certificate         /etc/letsencrypt/live/mywebiste.com/fullchain.pem;
    ssl_certificate_key     /etc/letsencrypt/live/mywebiste.com/privkey.pem;


       server_name  mywebiste.com/phpmyadmin;

       location / {
                root /usr/share/phpMyAdmin;
                index index.php;
                }

        location ~ \.php$ {
                fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$fastcgi_scr
ipt_name;
                include fastcgi_params;
        }
}

【问题讨论】:

    标签: nginx phpmyadmin centos


    【解决方案1】:

    不要在 server_name 变量中使用 uri 链接。这个变量只需要域名,没有httphttps/或其他符号。

    我稍微改变了你的配置:

    server {
        listen 443 ssl;
        server_name mywebiste.com;
    
        ssl_certificate /etc/letsencrypt/live/mywebiste.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/mywebiste.com/privkey.pem;
    
        root /usr/share/phpMyAdmin/;
    
        location / {
            index index.php;
            try_files $uri $uri/ /index.php?$query_string;
        }
    
        location ~ \.php$ {
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }
    

    在这种情况下,如果使用 URL https://mywebiste.comhttps://mywebiste.com/index.php,则打开 PhpMyAdmin。

    如果您需要此 URL https://mywebiste.com/phpMyAdmin/index.php,请在 location / 中更改变量 root。也可以使用单独的位置,例如67349181 问题。

    您可以使用nginx -t 命令验证配置。问题会一直写入错误日志,默认/var/log/nginx/error.log

    如果您需要更多信息,请说。

    【讨论】:

    • 亲爱的@qwsj 谢谢你再次帮助我。我很感激。我试过你的代码。但我收到了 404 错误,提示失败(2:没有这样的文件或目录)并且 [警告] 在 0.0.0.0:443 上的服务器名称“mywebsite.com”冲突,被忽略。 .and 我试图打开 http 链接它也变成 404 错误。
    • @blueink 对不起,我的错。我更新了配置。关于:And [warn] conflicting server name "mywebsite.com" on 0.0.0.0:443 通过nginx -T 检查完整配置,也许您有listen 443 ssl;server_name mywebiste.com; 的副本。
    • 亲爱的@qwsj 再次感谢您。我尝试了您的新答案,但是当我点击 http 时,结果是相同的 404。然后出现 Hit https ,502 Bad Gateway 错误。我做了 nginx -T 所以消息说 nginx.conf 语法没问题 并且测试成功并且仍然相同 [警告] 8341#8341: 冲突的服务器名称“mywebiste.con” on 0.0.0.0:443,忽略
    • @blueink 你可能有重复的配置,因为你可能会遇到问题。命令nginx -T(大写T)打印所有活动配置。多个主机具有相同的listen 是正常的,但server_name 中的域不应与相同的listen 重复,即使它们位于不同的配置中。代码502表示nginx和php-fpm的通信问题(这个代码一般在socket不可用的情况下出现——fpm停止,权限问题,socket不存在)。
    • 亲爱的@qwsj 谢谢。我读了你的评论,并试图解决这个问题。但这对我来说很难,结果没有改变。我在这些文件中做了 2 个虚拟域设置,这就是我的配置搞砸的原因。我做了 nginx -T 这是我的整个代码。你能看看吗? justpaste.it/7vc5p
    猜你喜欢
    • 2021-12-27
    • 2017-07-15
    • 1970-01-01
    • 2016-10-14
    • 1970-01-01
    • 2018-02-02
    • 2022-08-02
    • 2018-12-03
    • 2014-01-26
    相关资源
    最近更新 更多