Why is my nginx alias not working?
Figured out a way. I'm not sure if it's the BEST, but it's certainly working right now.
Here's what I did:
location ~ ^/phpmyadmin/(.*)$
{
alias /home/phpmyadmin/$1;
}
I'm not sure but have you tried writing it this way:
location /phpmyadmin/
{
alias /home/phpmyadmin/;
}
Also, what's the URI from which you are trying to access it?
As far as I understand it, you have to use the URI
/home/phpmyadmin/
and not just
/phpmyadmin/
You can read more about it here: http://wiki.nginx.org/HttpCoreModule
Try
location ^~ /phpMyAdmin/
{
alias /home/phpmyadmin/;
location ~ \.php$
{
include fcgi.conf;
fastcgi_index index.php;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_param SCRIPT_FILENAME /home$fastcgi_script_name;
}
}
The reason this doesn't work is the server is choosing the regex based location and not the prefix based location that has the alias in it.
It will only choose one. There is an operator you can use to get a prefix based location to outrank a regex one, but then you'll find php won't work. The solution will be one like kervin's answer where the PHP regex is nested inside the location with the alias directive.
I suspect however his SCRIPT_FILENAME setting may not work there since there is different capitalisation on the URL and the aliased directory.