>  기사  >  백엔드 개발  >  nginx localhost 구성, 디렉토리 검색 활성화

nginx localhost 구성, 디렉토리 검색 활성화

WBOY
WBOY원래의
2016-08-08 09:30:181146검색

과거에 Apache를 사용할 때 localhost에 액세스할 때 가끔 403 액세스가 종료되는 경우가 있었습니다. 그런데 때로는 구성을 수정하지 않고 며칠 후에 다시 작동하는 경우가 있었습니다. , 구성이 어떻게 수정되었는지에 관계없이 모든 프롬프트는 403 No Permission!입니다. 확률은 낮지만 해결된 적은 없습니다.

nginx로 변경한 후에는 이 문제가 더 이상 발생하지 않습니다. Autoindex를 사용하면 매우 재미있습니다.

구성 파일 localhost.conf:

http://localhost/phpmyadmin/ 별칭을 phpmyadmin으로 지정합니다!

server {
	listen       80;
	server_name  localhost 127.0.0.1 "";
	root d:/localhost;		
	index  index.html index.htm index.php;	
	
	autoindex on; 
	autoindex_exact_size off;
	autoindex_localtime on;			
	
	location /phpmyadmin {
		root d:/wamp/apps/phpmyadmin4.1.14;
		location ~ \.php$ {
			try_files $uri =404;
			fastcgi_pass   127.0.0.1:9000;
			fastcgi_index  index.php;
			fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
			include        fastcgi_params;    
		}	
	}
	
	location ~ \.php$ {
		try_files $uri =404;
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include        fastcgi_params;    
	}	
	


	
	

	#error_page  404              /404.html;

	# redirect server error pages to the static page /50x.html
	#
	
	error_page   500 502 503 504  /50x.html;
	location = /50x.html {
		root   html;
	}
	
	location ~ /\.(ht|svn|git) {
		deny all;
	}
}

위 내용은 내용을 포함하여 디렉토리 탐색을 가능하게 하는 nginx localhost 구성을 소개합니다. PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.