Home > Backend Development > PHP Tutorial > nginx怎么配置 目录别名phpmyadmin 到 localhost/phpmyadmin/

nginx怎么配置 目录别名phpmyadmin 到 localhost/phpmyadmin/

WBOY
Release: 2016-06-13 12:15:14
Original
1407 people have browsed it

nginx如何配置 目录别名phpmyadmin 到 localhost/phpmyadmin/
需求要求
在nginx中实现 类似Apache的 alias功能,将目录 /phpmyadmin 指向 D:/wamp/apps/phpmyadmin4.1.14

<br />#Apache写法<br />Alias /phpmyadmin "d:/wamp/apps/phpmyadmin4.1.14/"<br />
Copy after login


自己写法
<br />server {<br />	listen       80;<br />	server_name  localhost 127.0.0.1;<br />	root   d:/localhost;<br />	index  index.html index.htm index.php;			<br />	autoindex on; <br />	autoindex_exact_size off;<br />	autoindex_localtime on;			<br /><br />	location /phpmyadmin/ {<br />		alias D:/wamp/apps/phpmyadmin4.1.14;<br />		index index.php;<br />	}<br />	<br />	location ~ \.php$ {<br />		try_files $uri =404;<br />		fastcgi_pass   127.0.0.1:9000;<br />		fastcgi_index  index.php;<br />		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;<br />		include        fastcgi_params;    <br />	}<br />	<br />	#error_page  404              /404.html;<br /><br />	# redirect server error pages to the static page /50x.html<br />	#<br />	<br />	error_page   500 502 503 504  /50x.html;<br />	location = /50x.html {<br />		root   html;<br />	}<br />	<br />	location ~ /\.(ht|svn|git) {<br />		deny all;<br />	}<br />}<br /><br />
Copy after login


结果 访问 http://localhost/phpmyadmin 提示 404 Not Found。

日志信息:
<br />127.0.0.1 - - [10/Dec/2014:10:19:07 +0800] "GET /phpmyadmin HTTP/1.1" 404 142 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0" "-"<br />127.0.0.1 - - [10/Dec/2014:10:19:07 +0800] "GET /favicon.ico HTTP/1.1" 404 142 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0" "-"<br />127.0.0.1 - - [10/Dec/2014:10:19:07 +0800] "GET /phpmyadmin HTTP/1.1" 404 142 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0" "-"<br />127.0.0.1 - - [10/Dec/2014:10:19:08 +0800] "GET /favicon.ico HTTP/1.1" 404 142 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0" "-"<br />
Copy after login


失败,如何才可以实现nginx 的alias 指向phpmyadmin目录(如果是所有的server一起指向更好)。

------解决思路----------------------
将phpmyadmin放在root 对应的根目录下。
------解决思路----------------------
参考下:http://down.chinaz.com/server/201111/1382_1.htm

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template