尊龙凯时人生就是搏

NginxÐéÄâÖ÷»úÉèÖà £¬ÖÎÀí¶à¸öÍøÕ¾Èë¿Ú

nginxÐéÄâÖ÷»úÉèÖà £¬ÖÎÀí¶à¸öÍøÕ¾Èë¿Ú

ÔÚ»¥ÁªÍøµÄÉú³¤Àú³ÌÖÐ £¬½¨Éè×Ô¼ºµÄÍøÕ¾ÒѾ­³ÉΪÐí¶àÈ˵ÄÑ¡Ôñ¡£È»¶ø £¬Ëæ×ÅÍøÕ¾ÊýÄ¿µÄÔöÌí £¬ÔõÑùÓÐÓõØÖÎÀí¶à¸öÍøÕ¾Èë¿Ú³ÉΪÁËÒ»¸öÖ÷ÒªµÄÎÊÌâ¡£NginxÐéÄâÖ÷»úµÄÉèÖÿÉÒÔ×ÊÖúÎÒÃÇʵÏÖÕâһĿµÄ¡£

NginxÊÇÒ»¿î¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷ £¬¾ß±¸´¦Àí¸ß²¢·¢ÇëÇóµÄÄÜÁ¦¡£ÆäÐéÄâÖ÷»úÉèÖÃÄܹ»ÈÃÒ»¸öЧÀÍÆ÷ͬʱÍйܶà¸öÍøÕ¾ £¬²¢½«²î±ðµÄÍøÕ¾ÇëÇóת·¢µ½²î±ðµÄºó¶ËЧÀÍÆ÷ÉÏ¡£ÏÂÃæÎÒÃǽ«ÏÈÈÝÔõÑùʹÓÃNginx¾ÙÐÐÐéÄâÖ÷»úµÄÉèÖá£

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚNginxµÄÉèÖÃÎļþÖоÙÐÐÏìÓ¦µÄÉèÖá£Ò»Ñùƽ³£¶øÑÔ £¬NginxµÄÉèÖÃÎļþλÓÚ/etc/nginxĿ¼Ï¡£ÎÒÃÇ¿ÉÒÔʹÓÃí§ÒâÎı¾±à¼­Æ÷·­¿ª¸ÃÎļþ £¬¾ÙÐÐÉèÖá£

ÔÚÉèÖÃÎļþÖÐ £¬Ã¿¸öÐéÄâÖ÷»úµÄÉèÖö¼ÐèҪʹÓÃÒ»¸öserver¿éÀ´¾ÙÐÐÐÎò¡£Ã¿¸öserver¿éÖÐÐèÒªÖ¸¶¨¼àÌýµÄ¶Ë¿ÚºÍÐéÄâÖ÷»úµÄÓòÃû¡£ÀýÈ磺

server {
    listen 80;
    server_name www.example1.com;
    ...
}

server {
    listen 80;
    server_name www.example2.com;
    ...
}

µÇ¼ºó¸´ÖÆ

ÔÚÒÔÉϵÄʾÀýÖÐ £¬ÎÒÃǽç˵ÁËÁ½¸öserver¿é¡£Ò»¸ö¼àÌý80¶Ë¿Ú²¢½«ÇëÇóת·¢µ½www.example1.comÍøÕ¾ £¬ÁíÒ»¸ö¼àÌý80¶Ë¿Ú²¢½«ÇëÇóת·¢µ½www.example2.comÍøÕ¾¡£

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒªÉèÖÃÐéÄâÖ÷»úµÄ¸ùĿ¼ºÍÆäËûÏà¹ØµÄ²ÎÊý¡£ÀýÈ磺

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

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

µÇ¼ºó¸´ÖÆ

ÔÚÒÔÉϵÄʾÀýÖÐ £¬ÎÒÃÇΪÿ¸öÓòÃûÖ¸¶¨ÁËÏìÓ¦µÄ¸ùĿ¼¡£ÕâÑùµ±Óû§ÇëÇówww.example1.comʱ £¬Nginx»á½«ÇëÇóת·¢µ½/var/www/example1Ŀ¼Ï £¬¶øÇëÇówww.example2.comʱ £¬Ôò»áת·¢µ½/var/www/example2Ŀ¼Ï¡£

³ýÁ˸ùĿ¼ £¬ÎÒÃÇ»¹¿ÉÒÔÉèÖûá¼ûÈÕÖ¾¡¢¹ýʧҳÃæµÈÆäËûÏà¹ØµÄ²ÎÊý¡£ÀýÈ磺

server {
    listen 80;
    server_name www.example1.com;
    root /var/www/example1;
    access_log /var/log/nginx/example1.access.log;
    error_log /var/log/nginx/example1.error.log;
    ...
}

server {
    listen 80;
    server_name www.example2.com;
    root /var/www/example2;
    access_log /var/log/nginx/example2.access.log;
    error_log /var/log/nginx/example2.error.log;
    ...
}

µÇ¼ºó¸´ÖÆ

ÔÚÒÔÉϵÄʾÀýÖÐ £¬ÎÒÃÇΪÿ¸öÐéÄâÖ÷»úÉèÖÃÁË×ÔÁ¦µÄ»á¼ûÈÕÖ¾ºÍ¹ýʧÈÕÖ¾¡£ÕâÑù¿ÉÒÔÀû±ãÎÒÃǶÔÿ¸öÍøÕ¾µÄ»á¼û¾ÙÐмà¿ØºÍÆÊÎö¡£

×îºó £¬ÎÒÃÇÐèÒªÖØÆôNginxÒÔʹÉèÖÃÉúЧ¡£¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´ÖØÆôNginx£º

sudo service nginx restart

µÇ¼ºó¸´ÖÆ

ͨ¹ýÒÔÉϵÄÉèÖà £¬ÎÒÃÇ¿ÉÒÔͨ¹ý²î±ðµÄÓòÃû»á¼ûµ½²î±ðµÄÍøÕ¾ £¬²¢ÇÒÿ¸öÍøÕ¾¶¼¿ÉÒÔÓÐ×ÔÁ¦µÄ¸ùĿ¼¡¢»á¼ûÈÕÖ¾ºÍ¹ýʧÈÕÖ¾¡£

×ܽáÆðÀ´ £¬NginxµÄÐéÄâÖ÷»úÉèÖÿÉÒÔ×ÊÖúÎÒÃÇÖÎÀí¶à¸öÍøÕ¾Èë¿Ú¡£Í¨¹ýÉèÖüàÌýµÄ¶Ë¿Ú¡¢ÓòÃû¡¢¸ùĿ¼¡¢ÈÕÖ¾µÈ²ÎÊý £¬ÎÒÃÇ¿ÉÒÔÇáËɵØʵÏÖ¶à¸öÍøÕ¾µÄÍйܺÍÖÎÀí¡£Ï£Íû±¾ÎÄÄܶԸ÷ÈËÃ÷È·NginxÐéÄâÖ÷»úÉèÖÃÓÐËù×ÊÖú¡£

²Î¿¼Á´½Ó£º

https://www.nginx.com/

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-14-04-lts

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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