大网数据广告活动
服务器运维问答

phpmyadmin forbidden in Nginx although permited

· 52CE 我爱测

I fail to understand why entrance to PHPmyadmin is forbidden ( http://my_ip/phpmyadmin ). Here's what I did to install it: On a pure Ubuntu 16.04 machine (server, xenial) I've installed LEMP with php-fpm 7.0. Nginx conf is defaul…

问题原文

原帖链接 · Arcticooling · CC BY-SA 3.0

I fail to understand why entrance to PHPmyadmin is forbidden (http://my_ip/phpmyadmin). Here's what I did to install it:

On a pure Ubuntu 16.04 machine (server, xenial) I've installed LEMP with php-fpm 7.0. Nginx conf is default:

apt-get update -y
apt-get upgrade nginx mysql-server php-fpm php-mysql -y

I then installed PMA and permitted it:

DEBIAN_FRONTEND=noninteractive apt-get upgrade phpmyadmin php-mbstring php-mcrypt -y
ln -s /usr/share/phpmyadmin/ /var/www/html/
chown -R www-data:www-data /usr/share/phpmyadmin/ /var/www/html
chmod -R a-x,a=rX,u+w /usr/share/phpmyadmin/ /var/www/html

I really fail to understand what's wrong from the error log:

directory index of "/var/www/html/phpmyadmin/" is forbidden

What might cause PMA to be forbidden?

Update - general:

Update for Jenny:

I removed the symlink and added this conf inside the http block in nginx.conf and restarted the server, but no change is seen:

server {    
    location /phpmyadmin {
        index index.php index.html index.htm;
        root /usr/share;
    }
}

社区高分解答

原帖链接 · Jenny D · CC BY-SA 4.0

When you symlink a directory, you are telling nginx that "when you need to use /var/www/html/phpmyadmin, you should instead look at /usr/share/phpmyadmin/. And that directory is not under your webroot directory, so nginx won't be using it.

Instead of using a symlink, tell nginx to start using that directory directly. Example:

location /phpmyadmin {
     index index.php index.html index.htm;
     root /usr/share;
}

That will tell nginx that the location /phpmyadmin lives under /usr/share instead of under /var/www/html/.

Or, if the /usr/ and the /var/ file systems are on the same partition, you could do a hard link instead of a symlink. But that's likely to cause problems for you if you ever change the partition layout.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-01-30)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。