4

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; } } 
3
  • Have you tried to see the permissions of every directories in that path ? Have you see this answer? Can you show your nginx config file ? Commented Jan 30, 2018 at 8:21
  • I've added my Nginx conf and my fastcgi conf. Commented Jan 30, 2018 at 9:49
  • This answer is so helpful: stackoverflow.com/a/54370993/1770571 It works for me! Commented Mar 8, 2020 at 10:21

2 Answers 2

8

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.

3
  • Jenny I've edited the question and added an update for you. Commented Jan 30, 2018 at 9:51
  • @ALTegani If you have a NEW question, please ask it by clicking the Ask Question button. If you have sufficient reputation, you may upvote the question. Alternatively, "star" it as a favorite and you will be notified of any new answers. Commented Mar 3, 2018 at 18:42
  • when I remove the symbolic link I have a 404 Commented Feb 2, 2023 at 10:23
2

The message

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

indicates that nginx can't find the configured index document, so it tries to list the files (which is forbidden).

Check your index directive in your nginx configuration. It should contain index.php for phpMyAdmin.

Example:

index index.php index.html index.htm; 
6
  • Please edit your complete server block into your configuration, including your php fastcgi configuration. Commented Jan 30, 2018 at 8:46
  • Your nginx.conf is missing the complete configuration for running php scripts. Commented Jan 30, 2018 at 9:34
  • In great plea, please edit to add an example (should this come in nginx.conf or in a dedicated conf file?). Commented Jan 30, 2018 at 9:56
  • Using PHP scripts with nginx is very well documented. You can find the configuration easily with the search engine of your choice, and even on this site. Commented Jan 30, 2018 at 9:58
  • That's true, but for phpmyadmin, do you suggest me to use some global conf or particular conf (per script)? Commented Jan 30, 2018 at 10:11

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.