Nginx sets the alias directory, always 404 error.

Environment:

    CentOS 7.4 x64
    Nignx 1.14
    PHP 7.2.6
   

configuration file Nginx.conf root / root is / web/public, phpmyadmin is placed in / web/phpmyadmin,

location /phpmyadmin/ {
    alias /web/phpmyadmin/;
    index index.php index.html index.htm;
    location ~ ^/phpmyadmin/(.+?\.php)(/.*)?$ {
        alias /web/phpmyadmin/;
        fastcgi_split_path_info ^(.+?\.php)(/.*)?$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /web/phpmyadmin/$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ ^/phpmyadmin/(.+)\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)(/.*)?$ {
        alias /web/phpmyadmin/;
        expires 6d;
    }
}

the configuration code as above always prompts a 404 error.
Nignx error message: FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

if you use the root setting, there will be no problem, speechless.

location /phpmyadmin/ {
    root /web;
    index index.php index.html index.htm;
    location ~ ^/phpmyadmin/(.+?\.php)(/.*)?$ {
        root /web;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ ^/phpmyadmin/.*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico|js|css)$ {
        root /web;
        expires 7d;
    }
}
Mar.17,2021

  1. your configuration is also quite magical, why are you nesting it?
  2. is irregular, and the path corresponds to the last part of the path value of the instruction, for example:

    location ~ ^/phpmyadmin/(.+?\.php)(/.*)?$ {
          alias /web/$1;
    }
  3. is actually something on the document. Take a good look at it sometime.
Menu