以前使用Apache,有時候訪問localhost ,居然提示403 access die ,但有時過幾天又可以(沒有修改過任何配置的情況下),很詭異,出現這樣情況的時候不管是怎麼修改配置都是提示403無權限!幾率很低但一直無法解決。
換 nginx 後就沒有再出現這樣問題,autoindex 用的很爽。
設定檔 localhost.conf :
其中對 http://localhost/phpmyadmin/ alias別名到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教學有興趣的朋友有幫助。