L
L
littleguga2015-12-21 17:16:21
Nginx
littleguga, 2015-12-21 17:16:21

Why does it give 404 error (nginx+alias)?

This configuration works:

location /phpmyadmin {
   root /usr/share/;
   index index.php index.html index.htm;
   location ~ ^/phpmyadmin/(.+\.php)$ {
           try_files $uri =404;
           root /usr/share/;
           fastcgi_pass unix:/var/run/php5-fpm.sock;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include /etc/nginx/fastcgi_params;
   }
   location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
           root /usr/share/;
   }
}

I'm trying to hang up alias, and not set root.
location /pma {
    alias /usr/share/phpmyadmin;
    index index.php index.html index.htm;

    location ~ ^/pma/(.+\.php)$ {
            alias /usr/share/phpmyadmin/$1;
            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include /etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~* ^/pma/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
            alias /usr/share/phpmyadmin/$1;
    }
}

The .php files give 404, although .txt/.css and others are correct.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2015-12-21
@littleguga

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
and your root is /usr/share/
i.e. He's looking for/usr/share/pma/index.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question