×ðÁú¿­Ê±

NginxÐéÄâÖ÷»úÉèÖã¬Í¬Ê±Íйܶà¸öÍøÕ¾Èë¿Ú

nginxÐéÄâÖ÷»úÉèÖã¬Í¬Ê±Íйܶà¸öÍøÕ¾Èë¿Ú

NginxÊÇÒ»ÖÖ¸ßÐÔÄܵÄWebЧÀÍÆ÷£¬Ëü¿ÉÒÔ´¦Öóͷ£¸ß²¢·¢µÄÇëÇó²¢Ìṩ¿ìËÙµÄÏìÓ¦¡£ÔÚÏÖʵӦÓÃÖУ¬ÎÒÃǾ­³£ÐèÒªÍйܶà¸öÍøÕ¾Èë¿Ú£¬Õâ¾ÍÐèÒªÉèÖÃNginxµÄÐéÄâÖ÷»ú¡£±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃNginxÐéÄâÖ÷»ú£¬Í¬Ê±Íйܶà¸öÍøÕ¾Èë¿ÚµÄÒªÁì¡£

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚNginxµÄÉèÖÃÎļþÖнç˵¶à¸öserver¿é£¬Ã¿¸öserver¿é´ú±íÒ»¸öÍøÕ¾Èë¿Ú¡£¿ÉÒÔ½«ÒÔÏÂʾÀý²åÈëµ½NginxµÄÉèÖÃÎļþÖУº

server {
    listen 80;
    server_name www.example1.com;
    root /var/www/example1;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

server {
    listen 80;
    server_name www.example2.com;
    root /var/www/example2;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

µÇ¼ºó¸´ÖÆ

ÒÔÉÏʾÀýÖУ¬ÎÒÃǽç˵ÁËÁ½¸öserver¿é£¬»®·Ö´ú±íÁËwww.example1.comºÍwww.example2.comÁ½¸öÍøÕ¾Èë¿Ú¡£Ã¿¸öserver¿éÖж¼°üÀ¨ÁËlistenÖ¸ÁîÓÃÓÚÖ¸¶¨¼àÌýµÄ¶Ë¿Ú£¬server_nameÖ¸ÁîÓÃÓÚÖ¸¶¨ÓòÃû£¬rootÖ¸ÁîÓÃÓÚÖ¸¶¨ÍøÕ¾µÄ¸ùĿ¼£¬indexÖ¸ÁîÓÃÓÚÖ¸¶¨Ä¬ÈϵÄÊ×Ò³Îļþ¡£ÔÚlocation¿éÖУ¬ÎÒÃÇʹÓÃÁËtry_filesÖ¸ÁîÀ´´¦Öóͷ£ÇëÇó¡£

ÉèÖÃÍêÒÔÉÏÄÚÈݺó£¬ÉúÑIJ¢ÖØмÓÔØNginxµÄÉèÖÃÎļþ¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´ÑéÖ¤ÉèÖÃÎļþÊÇ·ñ׼ȷ£º

nginx -t

µÇ¼ºó¸´ÖÆ

ÈôÊÇûÓйýʧÌáÐÑ£¬ËµÃ÷ÉèÖÃÎļþûÓÐÓï·¨¹ýʧ¡£½ÓÏÂÀ´£¬ÎÒÃÇÐèÒª½«ÓòÃûÓëЧÀÍÆ÷µÄIPµØµã¾ÙÐÐÓ³Éä¡£¿ÉÒÔͨ¹ýÐÞ¸ÄÍâµØhostsÎļþ»òÕßÔÚDNSЧÀÍÆ÷ÖÐÌí¼ÓÏìÓ¦µÄÆÊÎö¼Í¼À´ÊµÏÖ¡£È·±£ÓòÃûÆÊÎöºó£¬Í¨¹ýä¯ÀÀÆ÷»á¼û¶ÔÓ¦µÄÓòÃû£¬¼´¿É¿´µ½ÏìÓ¦ÍøÕ¾µÄÄÚÈÝ¡£

ͬʱ£¬ÎÒÃÇÒ²¿ÉÒÔƾ֤ÐèÒªÉèÖøü¶àµÄserver¿éÀ´Íйܸü¶àµÄÍøÕ¾Èë¿Ú¡£Ö»ÐèÒª²Î¿¼ÒÔÉÏʾÀý£¬ÔÚÉèÖÃÎļþÖÐÌí¼ÓеÄserver¿é²¢¾ÙÐÐÏìÓ¦µÄÐ޸ļ´¿É¡£

ÖµµÃÒ»ÌáµÄÊÇ£¬ÒÔÉÏʾÀýÖÐʹÓÃÁË80¶Ë¿Ú×÷Ϊ¼àÌý¶Ë¿Ú¡£ÈôÊÇÐèҪʹÓÃÆäËû¶Ë¿Ú£¬Ç뽫listenÖ¸ÁîÖеĶ˿ںÅÐÞ¸ÄΪÏìÓ¦µÄÖµ¡£

×ܽ᣺

ͨ¹ýÉèÖÃNginxµÄÐéÄâÖ÷»ú£¬ÎÒÃÇ¿ÉÒÔÀû±ãµØͬʱÍйܶà¸öÍøÕ¾Èë¿Ú¡£Ã¿¸öÍøÕ¾Èë¿Ú¿ÉÒÔÓÐ×Ô¼ºµÄÓòÃûºÍ¸ùĿ¼£¬ÊµÏÖÁËÍøÕ¾µÄ¸ôÀëºÍ×ÔÁ¦ÐÔ¡£Í¨¹ý±¾ÎÄÌṩµÄʾÀý´úÂ룬ϣÍûÄܹ»×ÊÖú¶ÁÕß¿ìËٴ¶à¸öÍøÕ¾Èë¿ÚµÄÇéÐΣ¬²¢¸üºÃµØÓ¦ÓÃNginxµÄÓÅÊÆ¡£

ÒÔÉϾÍÊÇNginxÐéÄâÖ÷»úÉèÖã¬Í¬Ê±Íйܶà¸öÍøÕ¾Èë¿ÚµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

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

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

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