当我安装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 错误,但之后我收到了上述错误。 抱歉我的英语不好。
第1步:您需要使用命令行检查nginx服务器的状态:
sudo service nginx status
sudo service nginx restart
第 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
如果有什么想问的请留言。
您需要为 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;
}
}