phpmyadmin 文件位于此处/usr/share/phpmyadmin/
我有这个服务器块代码,它只允许我从以下位置访问 phpmyadmin http://vps-ip/
:
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /usr/share/phpmyadmin/;
index index.php index.html index.htm;
server_name ein;
location / {
root /usr/share/phpmyadmin/;
index index index.php;
try_files $uri/ $uri /index.php?q=$uri&&$args;
port_in_redirect off;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
access_log off;
log_not_found off;
expires max;
root /usr/share/phpmyadmin/;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin/$fastcgi_script_name;
include fastcgi_params;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_intercept_errors on;
fastcgi_ignore_client_abort off;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 360;
fastcgi_read_timeout 360;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
location ~ /.htaccess { deny all; log_not_found off; access_log off; }
location ~ /.htpasswd { deny all; log_not_found off; access_log off; }
location = /favicon.ico { allow all; log_not_found off; access_log off; }
location = /robots.txt { allow all; log_not_found off; access_log off; }
}
为了从 访问 phpmyadminhttp://vps-ip/phpmyadmin
并从 访问我的网站,我需要做哪些更改http://vps-ip/
?
好的,我找到了解决方案:
location ^~ /phpmyadmin/ {
alias /usr/share/phpmyadmin/;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass php;
}
}
答案1
这种做法叫做别名,基本上就是将某样东西设置到其他地方。我个人没有使用过 NGINX,但根据这个帖子,你应该使用:
location /phpmyadmin/ {
alias /usr/share/phpmyadmin/;
}
希望这会有所帮助。:)
答案2
您需要更改根目录。目前,您将其设置为root /usr/share/phpmyadmin/
。这意味着 nginx 认为http://vps-ip/
应该从 提供服务/usr/share/phpmyadmin/
。您想要共享的文件http://vps-ip/
位于 吗/usr/share/
?(对他们来说,这似乎是一个非常奇怪的地方,您可能应该为您的网站创建一个文件夹)。