Nginx can';找不到phpMyAdmin
您好,我已经安装了最新稳定版本的Nginex(1.4.4),并且还想安装phpMyAdmin,不幸的是,当我试图通过http://192在浏览器中打开phpMyAdmin时,出现了以下错误/phpmyadmin:Nginx can';找不到phpMyAdmin,nginx,Nginx,您好,我已经安装了最新稳定版本的Nginex(1.4.4),并且还想安装phpMyAdmin,不幸的是,当我试图通过http://192在浏览器中打开phpMyAdmin时,出现了以下错误/phpmyadmin: 404 Not Found nginx/1.4.4 Nginx找不到phpMyAdmin文件的确切原因是什么 这是my/etc/nginx/nginx.conf文件的内容: user nginx; worker_processes 4; error_log /var/log/
404 Not Found
nginx/1.4.4
Nginx找不到phpMyAdmin文件的确切原因是什么
这是my/etc/nginx/nginx.conf文件的内容:
user nginx;
worker_processes 4;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
许多问候语我遵循了nginx和phpMyAdmin上的说明,并通过以下命令链接了nginx和phpMyAdmin:
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html
(the folder "www" was replaced in the newer versions of Nginx through "html")
sudo service nginx restart
如果我现在尝试通过
“http://192…/phpmyadmin”
“我的浏览器”中出现以下错误:
403 Forbidden
nginx/1.4.4
如果我试图通过
“http://192…/phpmyadmin/index.php”
只下载index.php文件
许多问候语尝试在phpmyadmin位置和nginx www之间创建符号链接:
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html
在此之后,您可以获得403禁止,但应在服务器标记内添加index.php,其中index.html和其他标记为:
/etc/nginx/sites-available/default
然后重新启动nginx由于未知原因,这里提供的答案对我没有帮助。我怀疑conf文件的其他部分排除了进入phpmyadmin目录的可能性
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/www
我不想花太长时间来修复它,只需将我的工作conf文件从www.example.com复制到phpmyadmin.example.com,并将目录设置为/usr/share/phpmyadmin。然后,我重新加载了nginx-s,我很好地完成了这项工作,而不必去查清我在正确执行时遇到的403/502错误。我还认为,与域相比,随机黑客尝试脚本更安全,但这确实需要为域的DNS正确设置通配符,即,使地址解析到服务器
希望这能帮助那些在让phpmyadmin与nginx协同工作这一简单任务中受挫的人。正如user1941083所解释的那样。
您只需要在phpMyAdmin和站点目录之间创建一个符号链接
sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/www
然后,在/etc/nginx/sites available中修改nginx设置。
更改:
致:
在您的文档根目录中创建一个符号并不是一个好主意,这只是在www.phmyadmin快捷方式中遇到麻烦 正确的方法是创建一个名为php的文件并添加到/etc/nginx/sites available。您可以复制下面的文件,但可以将端口号更改为其他文件
server {
listen 30425;
# Don't want to log accesses.
#access_log /dev/null main;
access_log /var/log/nginx/php.acces_log main;
error_log /var/log/nginx/php.error_log info;
root /usr/share/phpmyadmin;
index index.php index.html index.htm;
error_page 401 403 404 /404.php;
location ~ .*.php$ {
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_NAME $http_host;
fastcgi_ignore_client_abort on;
}
}
现在,您需要将符号链接到站点启用目录
ln-s/etc/nginx/sites available/php//etc/nginx/sites enabled
现在需要将此代码添加到nginx.conf的日志设置部分
log_format main ‘$remote_addr – $remote_user [$time_local] ‘
‘”$request” $status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘ ;
现在您可以使用访问您的phpmyadmin,只需使用
http://domain-name-or-ip-address/phpmyadmin/index.php
有时Nginx不会自动使用index.php,我们必须告诉它,要么通过更改
Nginx.conf
文件中的位置,要么通过手动将index.php
添加到url中,就像上面所述。我知道这很晚了,但在网上遵循一些教程和建议后,我遇到了同样的问题,但没有效果。我也在这页上尝试了@STH答案,但仍然存在错误
我必须重新启动以下服务:
sudo systemctl restart nginx.service
sudo systemctl restart php-fpm
这就成功了:将守护进程配置为在引导时启动,以确保所有LEMP程序在任何服务器重新启动后自动启动:
sudo systemctl enable nginx mysqld php-fpm
phpmyadmin安装在哪里?可能php fpm服务未启动如果配置了端口,请不要忘记将其添加到防火墙中
sudo systemctl enable nginx mysqld php-fpm