尊龙凯时人生就是搏

Nginx¹ýʧҳÃæÉèÖã¬ÓÅÑÅ´¦ÀíÍøÕ¾¹ÊÕÏ

nginx¹ýʧҳÃæÉèÖã¬ÓÅÑÅ´¦ÀíÍøÕ¾¹ÊÕÏ

ÔÚÏÖ´ú»¥ÁªÍøʱ´ú£¬Ò»¸ö¸ß¶ÈÎȹ̺Ϳɿ¿µÄÍøÕ¾ÊÇÈκÎÆóÒµ»òСÎÒ˽ÈË×·ÇóµÄÄ¿µÄ¡£È»¶ø£¬ÓÉÓÚÖÖÖÖÔµ¹ÊÔ­ÓÉ£¬ÍøÕ¾¿ÉÄÜ»áÂÄÀú¹ÊÕÏ»ò¹ýʧ£¬Õâ¿ÉÄÜÊÇÓÉÓÚÍøÂçÎÊÌ⡢ЧÀÍÆ÷ÎÊÌâ»òÓ¦ÓóÌÐò¹ýʧµÈ¡£

ΪÁËÌṩ¸üºÃµÄÓû§ÌåÑéºÍÓÅÑŵش¦ÀíÈκοÉÄܱ¬·¢µÄ¹ýʧ£¬Nginx×÷Ϊһ¸öÇ¿Ê¢µÄWebЧÀÍÆ÷Èí¼þ£¬²»µ«Äܹ»Ìṩ¸ßÐÔÄܵÄЧÀÍ£¬»¹Äܹ»ÎÞаµØÉèÖùýʧҳÃæ¡£

ÔÚNginxÖУ¬¹ýʧҳÃæÉèÖúÜÊǼòÆÓ¡£Í¨¹ý±à¼­NginxµÄÉèÖÃÎļþ£¬Äú¿ÉÒÔÉèÖÃ×Ô½ç˵µÄ¹ýʧҳÃ棬²¢½«ÆäÓë¶ÔÓ¦µÄ¹ýʧ´úÂë¹ØÁªÆðÀ´¡£

Ê×ÏÈ£¬ÄúÐèÒª·­¿ªNginxµÄÉèÖÃÎļþ£¬¿ÉÒÔÊÇ/etc/nginx/nginx.conf»ò/etc/nginx/conf.d/default.conf£¬ÏêϸÎļþ·¾¶¿ÉÄÜ»áÓÐËù²î±ð£¬Æ¾Ö¤ÄúµÄ×°Ö÷½·¨¶ø¶¨¡£

ÔÚÉèÖÃÎļþÖÐÕÒµ½http¶Î£¬È»ºóÔڸöÎÄÚÌí¼ÓÒÔÏ´úÂ룺

http {
    # ...

    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;

    location = /40x.html {
        root /usr/share/nginx/html;
    }

    location = /50x.html {
        root /usr/share/nginx/html;
    }

    # ...
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖУ¬ÎÒÃÇÉèÖÃÁËÁ½¸ö¹ýʧҳÃ棺404Ò³ÃæºÍ50xÒ³Ãæ¡£404Ò³ÃæÊǵ±»á¼ûµÄ×ÊÔ´²»±£´æʱÏÔʾµÄÒ³Ã棬50xÒ³ÃæÊǵ±Ð§ÀÍÆ÷·µ»Ø500¡¢502¡¢503»ò504¹ýʧʱÏÔʾµÄÒ³Ãæ¡£

½ÓÏÂÀ´£¬ÎÒÃÇÐèÒª½¨ÉèÕâЩ¹ýʧҳÃ档ĬÈÏÇéÐÎÏ£¬Nginx¹ýʧҳÃæÓ¦¸ÃλÓÚ/usr/share/nginx/html/Ŀ¼Ï¡£ÔÚ¸ÃĿ¼Ï½¨ÉèÁ½¸öHTMLÎļþ404.htmlºÍ50x.html²¢Ìîд×Ô½ç˵µÄÄÚÈÝ¡£

404.htmlʾÀý´úÂ룺

<!DOCTYPE html>
<html>
<head>
    <title>404 - Not Found</title>
</head>
<body>
    <h1>404 - Not Found</h1>
    <p>¶Ô²»Æð£¬Äã»á¼ûµÄÒ³Ãæ²»±£´æ¡£</p>
</body>
</html>

µÇ¼ºó¸´ÖÆ

50x.htmlʾÀý´úÂ룺

<!DOCTYPE html>
<html>
<head>
    <title>50x - Server Error</title>
</head>
<body>
    <h1>50x - Server Error</h1>
    <p>¶Ô²»Æð£¬Ð§ÀÍÆ÷·ºÆðÎÊÌ⣬ÇëÉÔºóÔÙÊÔ¡£</p>
</body>
</html>

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢¹Ø±ÕÉèÖÃÎļþºó£¬ÖØмÓÔØNginxÉèÖãº

sudo service nginx reload

µÇ¼ºó¸´ÖÆ

ÏÖÔÚ£¬ÔÚÄúµÄÍøÕ¾ÉÏÈôÊÇ·ºÆð404¹ýʧҳÃæ»òЧÀÍÆ÷¹ýʧҳÃ棬Nginx»á×Ô¶¯ÏÔʾÄú×Ô½ç˵µÄ¹ýʧҳÃ棬¶ø²»ÊÇĬÈϵÄNginx¹ýʧҳÃæ¡£

³ýÁËÉèÖþ²Ì¬HTMLÒ³Ãæ×÷Ϊ¹ýʧҳÃ棬Äú»¹¿ÉÒÔʹÓö¯Ì¬¾ç±¾ÓïÑÔÌìÉú¹ýʧҳÃæ¡£ÀýÈ磬Äú¿ÉÒÔʹÓÃPHP¡¢Python»òÈκÎÆäËûÖ§³ÖµÄÓïÑÔÀ´ÌìÉú×Ô½ç˵¹ýʧҳÃæ¡£

ʾÀý´úÂëÈçÏ£º

error_page 404 /404.php;
error_page 500 502 503 504 /50x.php;

location = /40x.php {
    root /usr/share/nginx/html;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
}

location = /50x.php {
    root /usr/share/nginx/html;
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
}

µÇ¼ºó¸´ÖÆ

ÇëÈ·±£ÄúµÄЧÀÍÆ÷ÉÏÒÑ×°Öò¢ÉèÖÃÁËÏìÓ¦µÄ¾ç±¾ÓïÑÔÚ¹ÊÍÆ÷ºÍFastCGIЧÀÍ¡£

ͨ¹ýÕâÖÖ·½·¨£¬Äú¿ÉÒÔƾ֤ÏÖʵÐèÇóÌìÉú¸ü¾ßÓн»»¥ÐԺ͸öÐÔ»¯µÄ¹ýʧҳÃ棬Ìṩ¸üºÃµÄÓû§ÌåÑé¡£

×ܶøÑÔÖ®£¬ÉèÖÃNginxµÄ¹ýʧҳÃæÊÇÒ»Ïî¼òÆÓ¶øÇ¿Ê¢µÄ¼¼ÇÉ£¬¿ÉÒÔ×ÊÖúÎÒÃÇÓÅÑŵش¦ÀíÍøÕ¾¹ÊÕÏ¡£ÎÞÂÛÊÇ404Ò³ÃæÕÕ¾ÉЧÀÍÆ÷¹ýʧҳÃ棬ͨ¹ý×Ô½ç˵¹ýʧҳÃ棬ÎÒÃÇ¿ÉÒÔÌṩ¸üºÃµÄÓû§ÌåÑ飬²¢ÏòÓû§×ª´ïÓÐÓõÄÐÅÏ¢¡£Í¬Ê±£¬ÎÒÃÇÒ²¿ÉÒÔʹÓþ籾ÓïÑÔÀ´ÌìÉú¶¯Ì¬µÄ¹ýʧҳÃ棬ÒÔÖª×ã¸ü¸ß¼¶µÄÐèÇó¡£

Ï£Íû±¾ÎĶÔÄúÃ÷È·ºÍÉèÖÃNginx¹ýʧҳÃæÓÐËù×ÊÖú£¡

ÒÔÉϾÍÊÇNginx¹ýʧҳÃæÉèÖã¬ÓÅÑÅ´¦ÀíÍøÕ¾¹ÊÕϵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ