Nginnx出現403 Forbiddenの解決方法
2560 ワード
Nginnxも現在流行しているライト級のサーバーです. 日常的に使っていますが、問題もあります. 今日は学習君がNginnxを設置する時に403 Forbinddenの訪問禁止のエラーが発生しました. ネットで検索したら完璧に解決します. ここで皆さんに分かち合います.
話は多くなくて、先に原版のnginx配置ファイルのコードを貼り付けます.
まず403の出現の原因を言います.
このアドレスにアクセスするとindex.htm,index.phpの順にルートディレクトリでファイルを検索します.これらの3つのファイルが存在しない場合、inxは403 Forbiddenに戻ります.
君根カタログの下にもこの3つの書類がないので、直接に勉強します.
ここで注意します
autindex onこのデフォルトはoffです. ディレクトリへのアクセス禁止という意味です. オープンが必要です
もう一つお勧めしたいのですが、この書類に配置項目を全部書かないでください.管理しにくいです.
一緒に勉強しましょう
話は多くなくて、先に原版のnginx配置ファイルのコードを貼り付けます.
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
autoindex on;
keepalive_timeout 65;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
#gzip on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 32k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_disable "MSIE [1-6].";
server_names_hash_bucket_size 128;
client_max_body_size 100m;
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
server {
listen 80;
server_name localhost;
autoindex on; #
root "C:/WWW";
location / {
index index.html index.htm l.php;
#index.php
autoindex on;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
include vh_*.conf;
}
このように多くのファイルコードを配置しています.(コメントを見やすくするために、分かりません.削除しました.) 勉強君も読めないです.まず403の出現の原因を言います.
このアドレスにアクセスするとindex.htm,index.phpの順にルートディレクトリでファイルを検索します.これらの3つのファイルが存在しない場合、inxは403 Forbiddenに戻ります.
君根カタログの下にもこの3つの書類がないので、直接に勉強します.
root "C:/WWW";
location / {
index index.html index.htm l.php;
#index.php
autoindex on;
}
コメント プロジェクトリストが表示されます.ここで注意します
autindex onこのデフォルトはoffです. ディレクトリへのアクセス禁止という意味です. オープンが必要です
もう一つお勧めしたいのですが、この書類に配置項目を全部書かないでください.管理しにくいです.
include vh_*.conf;
は導入できます. このようなドメイン名の設定ファイル 便利な管理一緒に勉強しましょう