如何配置Nginx和Adminer

nszi6y05  于 2023-06-05  发布在  Nginx
关注(0)|答案(2)|浏览(225)

我在kali linux上安装了Nginx服务器,我通过在浏览器中输入localhost来访问它。然后我安装了Adminer,以便以图形方式管理我的数据库,但当我在浏览器中输入http://localhost/adminer时,我收到了404 Not found
我不知道我在哪里错过了!
这里是我的/etc/nginx/sites-available的内容

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

# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;

root /usr/share/adminer;

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

server_name localhost;

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/php7.4-fpm.sock;
    # With php-cgi (or other tcp sockets):
#   fastcgi_pass 127.0.0.1:9000;
}

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

这里是/log/nginx/error.log的内容

2020/09/02 07:43:47 [error] 71583#71583: *1 "/usr/share/nginx/html/adminer/index.html" is 
 not found (2: No such file or directory), client: ::1, server: , request: "GET /adminer/ 
 HTTP/1.1", host: "localhost"

根据错误消息,它的/usr/share/nginx/html目录不包含adminer文件夹,这是真的,因为我没有这个文件夹在该位置。所以我不知道为什么Nginx在那里寻找它,或者它是否应该在那里;如果是这样,为什么它不在那里?我怎么解决这个问题?

w1jd8yoj

w1jd8yoj1#

Nginx正在寻找一个'index.html'里面的路径不是你的根指令,这是一个事实:“/usr/share/nginx/html/adminer/index.html”未找到
执行以下步骤,轻松修复:
1.如果您的文件系统中没有此路径:“/usr/share/adminer”,创建它,因为它是你的conf文件中的根目录。
1.将adminer文件复制到此目录并将其重命名为index.php
1.更新conf文件中的index指令,包括index.php:
index index.php index.html index.htm index.nginx-debian.html;
1.确保你有一个simlink到你的“/etc/nginx/sites-available/your.conf”在“/etc/nginx/sites-enabled”,否则你的vhost conf将无法加载,它将无法工作。
/etc/nginx/sites-available/your.conf /etc/nginx/sites-enabled/
完成,重新加载服务器,一切正常。

6qqygrtg

6qqygrtg2#

Adminer基于adminer.php。您需要将adminer.php放在index指令中。帮我解决了。

相关问题