我收到一个文件而不是访问 PhpMyAdmin 页面

问题描述 投票:0回答:2

当我安装Php,PhpMyAdmin和Nginx时,我用这些代码文件接收了这个文件,而不是访问

http://localhost:80/phpmyadmin

<?php

declare(strict_types=1);

use PhpMyAdmin\Routing;

if (! defined('ROOT_PATH')) {
    // phpcs:disable PSR1.Files.SideEffects
    define('ROOT_PATH', __DIR__ . DIRECTORY_SEPARATOR);
    // phpcs:enable
}

global $route, $containerBuilder;

require_once ROOT_PATH . 'libraries/common.inc.php';

$dispatcher = Routing::getDispatcher();
Routing::callControllerForRoute($route, $dispatcher, $containerBuilder);

我就是这么做的 nginx 中的 phpmyadmin 404 错误 修复 404 错误,但之后我收到了上述错误。 抱歉我的英语不好。

php ubuntu nginx phpmyadmin
2个回答
1
投票

第1步:您需要使用命令行检查nginx服务器的状态:

sudo service nginx status

  • 如果 nginx 服务器未激活,请尝试使用命令行重新启动 nginx 服务器
    sudo service nginx restart
  • 如果您看到失败,让我们检查一下端口 80 上正在运行什么程序(请在评论中告诉我)。常见错误是由在端口 80 上运行的 apache2 服务器引起的(如果是这样,请转到下一步)。

第 2 步:有两种解决方案适合您

1, 使用此逗号行停止服务器 apache2:

sudo service apache2 stop

重启nginx服务器:

sudo service nginx restart

再次检查nginx服务器状态,现在应该没问题了。

2、更改端口apache2 您需要更改两个文件

/etc/httpd/conf/httpd.conf
/etc/apache2/ports.conf

例如,我将端口apache2从80更改为8888:

sudo nano /etc/apache2/ports.conf
并将
Listen 80
更改为
Listen 8888

sudo nano /etc/apache2/ports.conf
并将
<VirtualHost: *:80>
更改为
<VirtualHost: *:8080>

之后,重新启动apache2服务器和nginx服务器:

  • 重新启动apache2服务器:

    sudo service apache2 restart

  • 重启nginx服务器:

    sudo service nginx restart

如果有什么想问的请留言。


0
投票

您需要为 nginx 安装正确的 php 包

sudo apt-get install php8.1-fpm -y

您还需要有一个正确的 nginx 配置文件(此处为 localhost)

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
    #
    #   # With php-fpm (or other unix sockets):
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    }

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

© www.soinside.com 2019 - 2024. All rights reserved.