I've been trying to set up phpmyadmin on my nginx server using this outdated tutorial from DigitalOcean. The idea is to have the following configuration:
http(s)://example.com
=> /usr/share/nginx/html
http(s)://example.com/phpmyadmin
=> /usr/share/phpmyadmin
The tutorial's "solution" is to just create a symlink in /usr/share/nginx/html
that points to /usr/share/phpmyadmin
. This is the same approach used in this question. Unfortunately, this creates some other problems which I won't go into here.
It seems to me that I should be able to use individual location
blocks to control this behavior. I've tried the approach suggested here:
server {
listen 80 default;
server_name localhost;
root /usr/share/nginx/html;
index index.php index.html index.htm index.nginx-debian.html;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
location /phpmyadmin {
root /usr/share/phpmyadmin;
}
location ~ /phpmyadmin/.+\.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin$fastcgi_script_name;
}
}
I can still reach nginx's default page at http://example.com
, and even execute PHP scripts via URLs such as http://example.com/info.php
. Unfortunately, whenever I try to visit any http://example.com/*
URL, I get a 404 error.
How should I configure this properly? I'm running PHP7.0 with PHP-FPM on a Ubuntu server.