无法在 debian 下使用 nginx 访问 phpmyadmin“未指定输入文件”。

无法在 debian 下使用 nginx 访问 phpmyadmin“未指定输入文件”。

我已经安装了 Nginx、php-fpm、mysql 和 phpmyadmin。

当我输入 myserver.com 时,我看到“欢迎使用 nginx!”。

但当我输入 myserver.com/phpmyadmin 时,我得到了:“未指定输入文件。”我知道这可能是路径问题,但我找不到在哪里……:S

配置文件:

/etc/nginx/站点可用/默认

server {
        listen   80; ## listen for ipv4; this line is default and implied
        listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

        root /usr/share/nginx/www;
        index index.php  index.html index.htm;

        # Make site accessible from http://localhost/
        server_name _;

        location / {

                try_files $uri $uri/ /index.html;

        }

        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                allow ::1;
                deny all;
        }


        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;

                #fastcgi_pass 127.0.0.1:9000;

                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

}

/etc/nginx/sites-availables/www.myserver.com.vhost

server {
       listen 80;
       server_name www.server.com server.com;
       root /usr/share/nginx/www.akdom.net;
       if ($http_host != "www.akdom.net") {
                 rewrite ^ http://www.akdom.net$request_uri permanent;
       }
       index index.php index.html;
       location = /favicon.ico {
                log_not_found off;
                access_log off;
       }
       location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
       }
       # Make sure files with the following extensions do not get loaded by nginx because nginx would display the s$
        location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..$
                deny all;
        }
       # Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
       location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
       }
       location ~*  \.(jpg|jpeg|png|gif|css|js|ico)$ {
                expires max;
                log_not_found off;
       }
       location ~ \.php$ {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       }
        location /phpmyadmin {
               root /usr/share/;
               index index.php index.html index.htm;
               location ~ ^/phpmyadmin/(.+\.php)$ {
                       try_files $uri =404;
                       root /usr/share/;
                       fastcgi_pass 127.0.0.1:9000;
                       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/;
               }
        }
        location /phpMyAdmin {
               rewrite ^/* /phpmyadmin last;
        }
}

/usr/共享/我有 phpmyadmin/、nginx/www/ 和 nginx/www.exemple.com/

如何修复此错误?是什么原因造成的?

谢谢你的时间。

答案1

在文件 /etc/nginx/sites-availables/www.myserver.com.vhost 上

root /usr/share/;将location /phpmyadmin 中的行更改为:root /usr/share/phpmyadmin/;

答案2

您是这里位置选择规则的受害者。

为了实现此功能,您需要将 location /phpmyadmin 的优先级设置为高于 location ~ .php$。为此,我们必须考虑文档说明了位置

基本上,比正则表达式位置更具体的唯一位置是完全匹配 = 和负正则表达式位置 ^~

精确匹配在这里不是一个好的选择,所以我们需要使用负正则表达式位置。

    location ^~ /phpmyadmin {
           root /usr/share;
           index index.php index.html index.htm;

           location ~ \.php$ {
                   try_files $uri =404;

                   fastcgi_pass 127.0.0.1:9000;

                   fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                   include /etc/nginx/fastcgi_params;
           }

           location ~* \.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
                   root /usr/share; # If you're only setting root then this is not needed.
           }

           location ~ /\. { # We need to duplicate this so that we don't serve htaccess/passwd files for this subdir.
                   deny all;
                   access_log off;
                   log_not_found off;
           }
    }

相关内容