我正在尝试在我的 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。
您是否对 php-cgi 进行了 chroot 操作?那么所有路径都必须相对于该 chroot。