Maison >développement back-end >tutoriel php >nginx怎么配置 目录别名phpmyadmin 到 localhost/phpmyadmin/

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

WBOY
WBOYoriginal
2016-06-13 12:15:141410parcourir

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 />


自己写法
<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 />


结果 访问 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 />


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

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

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn