nginx403Ôõô½â¾ö
ÔõÑù½â¾ö nginx 403 forbidden ¹ýʧ£¿¼ì²éÎļþ»òĿ¼ȨÏÞ£»2. ¼ì²é .htaccess Îļþ£»3. ¼ì²é nginx ÉèÖÃÎļþ£»4. ÖØÆô nginx¡£ÆäËû¿ÉÄÜÔµ¹ÊÔÓÉ»¹°üÀ¨·À»ðǽ¹æÔò¡¢selinux ÉèÖûòÓ¦ÓóÌÐòÎÊÌâ¡£
ÔõÑù½â¾ö Nginx 403 Forbidden ¹ýʧ
Ö±ÑÔ²»»äµÄ»Ø¸²£º
Nginx 403 Forbidden ¹ýʧÌåÏÖ¿Í»§¶ËûÓÐȨÏÞ»á¼ûÇëÇóµÄ×ÊÔ´¡£½â¾ö´ËÎÊÌâµÄ³£¼û°ì·¨°üÀ¨£º
ÏêϸÕö¿ª»Ø¸²£º
1. ¼ì²éÎļþ»òĿ¼ȨÏÞ£º
È·±£ÇëÇóµÄ×ÊÔ´¾ßÓÐÊʵ±µÄÎļþ»òĿ¼ȨÏÞ¡£Í¨³££¬Ð§ÀÍÆ÷Ó¦¾ßÓжÁÈ¡ºÍÖ´ÐÐȨÏÞ£¬¶øÓû§Ó¦½ö¾ßÓжÁȡȨÏÞ¡£
ʹÓà ls -l ÏÂÁî¼ì²éÎļþ»òĿ¼µÄȨÏÞ£¬²¢Æ¾Ö¤ÐèҪʹÓà chmod ÏÂÁîµ÷½âËüÃÇ¡£
2. ¼ì²é .htaccess Îļþ£º
.htaccess Îļþ¿ÉÄÜ°üÀ¨ÏÞÖÆ»á¼ûµÄ¹æÔò¡£¼ì²éÎļþÊÇ·ñ±£´æ£¬²¢È·±£Ëü²»°üÀ¨¾Ü¾ø»á¼ûÇëÇóµÄ¹æÔò¡£
3. ¼ì²é Nginx ÉèÖÃÎļþ£º
·¿ª Nginx ÉèÖÃÎļþ (/etc/nginx/nginx.conf »ò /usr/local/etc/nginx/nginx.conf) ²¢¼ì²éÒÔÏ¿飺
location / { # ÔÊÐí»ò¾Ü¾ø»á¼ûµÄ¹æÔò }
µÇ¼ºó¸´ÖÆ
È·±£ÔÊÐí»á¼ûÇëÇóµÄ×ÊÔ´¡£ÈôÊÇÕÒ²»µ½ÈκÎÏÔʽ¾Ü¾ø¹æÔò£¬¿ÉÒÔʵÑéÌí¼Ó allow all; ÐÐÒÔÔÊÐíËùÓÐÇëÇó¡£
4. ÖØÆô Nginx£º
ÔÚ¾ÙÐÐÈκθü¸Äºó£¬Ê¹ÓÃÒÔÏÂÏÂÁîÖØÆô Nginx ÒÔÓ¦Óøü¸Ä£º
sudo systemctl restart nginx
µÇ¼ºó¸´ÖÆ
5. ÆäËû¿ÉÄܵĽâ¾ö¼Æ»®£º
·À»ðǽ¹æÔò£ºÈ·±£·À»ðǽûÓÐ×èÖ¹¶ÔÇëÇó×ÊÔ´µÄ»á¼û¡£
SELinux ÉèÖãºÈôÊÇÆôÓÃÁË SELinux£¬Ôò¿ÉÄÜÐèÒªµ÷½âÉèÖÃÒÔÔÊÐí»á¼û×ÊÔ´¡£
Ó¦ÓóÌÐòÎÊÌ⣺ÈôÊÇ Nginx Ö»ÊÇ×÷Ϊ·´ÏòÊðÀí£¬ÔòÎÊÌâ¿ÉÄܳöÔÚÓ¦ÓóÌÐòÖС£¼ì²éÓ¦ÓóÌÐòµÄÈÕÖ¾ÒÔ²éÕÒÈκιýʧÐÂÎÅ¡£
ÒÔÉϾÍÊÇnginx403Ôõô½â¾öµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡