国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > Nginx > 正文

詳解Nginx 出現(xiàn) 403 Forbidden 的解決辦法

2024-08-30 12:29:07
字體:
供稿:網(wǎng)友

Nginx 也是當(dāng)前流行的一款 輕量級(jí)服務(wù)器  在日常使用中呢 也會(huì)出現(xiàn)一些問題  今天 學(xué)習(xí)君 在安裝配置Nginx的時(shí)候就出現(xiàn)了 403 Forbindden 的被禁止訪問的錯(cuò)誤   網(wǎng)上搜索之后呢 完美解決  這里給大家分享下

話不多說 先粘 上 原版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;  } 

這么多配置文件代碼(為了便于查看 已經(jīng)把注釋的那些不懂的刪除)  學(xué)習(xí)君也是看不懂的

先說403 出現(xiàn)的原因

當(dāng)訪問該地址的時(shí)候,nginx 會(huì)按照 index.html,index.htm ,index.PHP 的先后順序在根目錄中查找文件。如果這三個(gè)文件都不存在,那么nginx就會(huì)返回403 Forbidden。

學(xué)習(xí)君根目錄下也是沒有這三個(gè)文件的 所以直接

root  "C:/WWW";  location / {    index index.html index.htm l.php;    #index.php    autoindex on;  } 

注釋   項(xiàng)目列表就展示出來了

這里要注意

autoindex on; 這個(gè)默認(rèn)是off的 意思是禁止訪問目錄  需要開啟

還有一點(diǎn)推薦大家別把配置項(xiàng) 都寫在這個(gè)文件當(dāng)中 不便于管理 

include vh_*.conf; 

可以引入這樣一個(gè)域名一個(gè)配置文件方便管理

以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 芜湖县| 博乐市| 峨山| 来宾市| 商南县| 始兴县| 涿州市| 乐都县| 永川市| 南投市| 花莲市| 济南市| 辉南县| 绵竹市| 宾川县| 上虞市| 南康市| 福建省| 金乡县| 合作市| 札达县| 项城市| 灵丘县| 神农架林区| 内丘县| 柘城县| 镶黄旗| 万盛区| 泗阳县| 宽甸| 武山县| 贡嘎县| 曲沃县| 吴江市| 南乐县| 遂川县| 琼中| 项城市| 肥城市| 长沙县| 常山县|