×ðÁú¿­Ê±¹ÙÍøµÇ¼

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
ÍøÕ¾µØͼ