3

I have a laptop running Ubuntu 16.10 (Mate), which I use as a local server just for testing websites that I develop. I recently switched from Apache2 to NginX. I have successfully set up NginX so that all my PHP based sites are running, and I get the output of phpinfo(), so I have PHP working.

The instructions I've found for getting phpMyAdmin to work with NginX seemed pretty simple:

  1. sudo ln -s /usr/share/phpmyadmin /usr/share/nginx/html/
  2. sudo service nginx restart
  3. clear the browser cache
  4. Open phpMyAdmin in the browser at localhost/phpmyadmin

I did all those steps, but I get a 404 not found error. I've tried moving the symlink to phpMyAdmin to different places, such as /var/www, which is where my other websites are, but it hasn't helped. It seems no matter where I put phpMyAdmin, it won't open.

What is the correct way to set up phpMyAdmin so that I can open it on my local NginX server?

2 Answers 2

5
  1. While installing phpmyadmin, select apache2 and install it, it copies the necessary files.
  2. Nginx uses /var/www/html/ as default web server root. So use ln -s /usr/share/phpmyadmin /var/www/html.
  3. If you changed web server root, instead of /var/www/html, use your path and make sure you set the right permissions.
  4. Open your browser and open localhost/phpmyadmin, you should open phpMyAdmin.
2
  • As an additional note, after correcting the symlink location, I also had to make sure the file /ett/nginx/sites-available/default had the correct PHP configuration, as figured out in this answer.
    – Questioner
    Jan 8, 2017 at 7:05
  • yes, thank you for completing the answer @Questioner Jan 8, 2017 at 9:09
2

In Apache2 the symlink would work because of the Apache2 alias module. In Nginx things work different. One way to solve this could be to create a new vhost for Nginx. Here is the relevant part, changing the root, and adding the index.php :


    root /usr/share/phpmyadmin;

    # 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;
    }

Another solution is to read more about aliases with Nginx. Here is a quick search result :

http://nginx.org/en/docs/http/ngx_http_core_module.html#alias

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .