2

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?

3

1.While installing phpmyadmin, select apache2 and install it, it copies necessary files.

2.Nginx use /var/www/html/ for default web server root. so use ln -s /usr/share/phpmyadmin /var/www/html.

3.If you changed web server root, istead 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.

  • 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 '17 at 7:05
  • yes, thank you for completing the answer @Questioner – Sadegh Alirezaie Jan 8 '17 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

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.