nginx phpmyadmin 404

nginx phpmyadmin 404

我正在嘗試在我的 nginx Web 伺服器上安裝 phpmyadmin。我安裝了 phpmyadmin 沒有問題。我為它創建了子網域。出於安全原因,我沒有將我的子網域稱為“phpmyadmin”,而是使用了不同的名稱。然後我將此配置用於我的子網域

server {
    listen   80;
    server_name myphpmyadminsubdomain.domain.com;
    access_log off;
    error_log /srv/www/myphpmyadminsubdomain/error.log;

    location / {
                root   /usr/share/phpmyadmin;
                index  index.php;
                }

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

    fastcgi_split_path_info ^(.+\.php)(/.+)$;

    include fastcgi_params;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#   fastcgi_intercept_errors on;
    fastcgi_pass php;
}

location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

location ~ /\. {
    deny all;
    access_log off;
    log_not_found off;
}
      }

然後我像這樣啟用它;

/etc/nginx/sites-available/myphpmyadminsubdomain /etc/nginx/sites-enabled/myphpmyadminsubdomain

我已重新啟動 nginx 並轉到 myphpmyadminsubdomain.domain.com,它給我 nginx 404 Not Found 錯誤。

我究竟做錯了什麼?

答案1

這是我的配置

server {
    listen 80; ## listen for ipv4
    server_name pma.example.com;
    access_log /var/log/nginx/pma.access.log;
    error_log       /var/log/nginx/pma.error.log;
    root /server/phpmyadmin/phpMyAdmin-3.4.2-all-languages;

    location / {
            index index.php index.html;
    }

    location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            include /etc/nginx/fastcgi_params;
            fastcgi_intercept_errors off;
            fastcgi_pass php;
    }

}

根應更改為/usr/share/phpmyadmin,並且fastcgi_params應適當更改。

答案2

一般是路徑問題。在nginx.conf中設置

fastcgi_param SCRIPT_FILENAME /absolute/path/to/server/root$fastcgi_script_name;

請注意,路徑中最後一個目錄後面沒有斜線。其次,fastcgi_pass 到套接字或本地 URL。

你正在chroot你的php-cgi嗎?那麼所有路徑都必須相對於該 chroot。

相關內容