PHPmyadmin文件位于/usr/share / PHPmyadmin /
我有这个服务器块代码,只允许我从http:// vps-ip /访问PHPmyadmin:
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; } }
为了从http:// vps-ip / PHPmyadmin访问PHPmyadmin并从http:// vps-ip /访问我的网站,我需要做些什么更改?
好的,我找到了解决方案:
location ^~ /PHPmyadmin/ { alias /usr/share/PHPmyadmin/; location ~ \.PHP${ include fastcgi_params; fastcgi_param SCRIPT_FILENAME $request_filename; fastcgi_pass PHP; } }
最佳答案
这样做的行为称为别名,基本上设置一些东西去其他地方.我个人没有Nginx的经验,但根据this post,您应该使用:
location /PHPmyadmin/ { alias /usr/share/PHPmyadmin/; }
希望这会有所帮助.
原文链接:https://www.f2er.com/nginx/435723.html