nginxÔõôÉèÖÃÏÔʾÓòÃû
ÔÚ nginx ÖÐÉèÖÃÏÔʾÓòÃûÐèÒªÒÔÏ°취£º±à¼ÉèÖÃÎļþ£¨Í¨³£Îª /etc/nginx/nginx.conf£©¡£Ìí¼ÓЧÀÍÆ÷¿é£¬Ö¸¶¨ÄúµÄÓòÃû¼°ÆäÓÖÃû£¨ÀýÈ磺server { listen 80; server_name example.com www.example.com; }£©¡£Ö¸¶¨ web ¸ùĿ¼£¨ÀýÈ磺root /var/www/example.com;£©¡£ÉúÑÄÉèÖÃÎļþ²¢ÖØмÓÔØ nginx£¨sudo nginx -t && sudo nginx -s reload£©¡£ÑéÖ¤ÉèÖ㬻á¼ûÄúµÄÓò
ÔõÑùÔÚ Nginx ÖÐÉèÖÃÏÔʾÓòÃû
ÔÚ Nginx ÖÐÉèÖÃÏÔʾÓòÃûÊ®·Ö¼òÆÓ¡£ÒÔÏ°취½«Ö¸µ¼ÄúÍê³É¸ÃÀú³Ì£º
1. ±à¼ Nginx ÉèÖÃÎļþ
ʹÓÃÎı¾±à¼Æ÷·¿ª Nginx µÄÉèÖÃÎļþ£¨Í¨³£Î»ÓÚ /etc/nginx/nginx.conf£©¡£
2. Ìí¼ÓЧÀÍÆ÷¿é
ÔÚÉèÖÃÎļþÖУ¬Ìí¼ÓÒ»¸öеÄЧÀÍÆ÷¿éÈçÏ£º
server { listen 80; server_name example.com www.example.com; }
µÇ¼ºó¸´ÖÆ
½« example.com Ì滻ΪÄúµÄÓòÃû¡£Äú»¹¿ÉÒÔÌí¼ÓÄúÏ£Íû Nginx ÏÔʾµÄÈκÎÓÖÃû£¬ÀýÈç www.example.com¡£
3. ÉèÖøùĿ¼
ÔÚЧÀÍÆ÷¿éÖУ¬Ö¸¶¨ Web ¸ùĿ¼£¬ÆäÖаüÀ¨ÄúÏ£ÍûÏÔʾµÄÍøÕ¾Îļþ£º
root /var/www/example.com;
µÇ¼ºó¸´ÖÆ
½« /var/www/example.com Ì滻ΪÄúµÄÍøÕ¾¸ùĿ¼¡£
4. ÉúÑIJ¢ÖØмÓÔØ Nginx
ÉúÑÄÉèÖÃÎļþ²¢ÖØмÓÔØ Nginx ÒÔÓ¦Óøü¸Ä£º
sudo nginx -t # ²âÊÔÉèÖÃÎļþµÄÓï·¨ sudo nginx -s reload # ÖØмÓÔØ Nginx ÉèÖÃ
µÇ¼ºó¸´ÖÆ
5. ÑéÖ¤ÉèÖÃ
»á¼ûÄúµÄÓòÃû£¨ÀýÈ磬http://example.com£©£¬ÄúÓ¦¸Ã»á¿´µ½ÄúÍøÕ¾µÄÎļþ¡£
×¢ÖØ£º
È·±£ÄúµÄÓòÃûÒÑ׼ȷÆÊÎöµ½ÄúµÄЧÀÍÆ÷ IP¡£
Äú¿ÉÄÜÐèҪƾ֤ÄúµÄÌض¨ÉèÖõ÷½âЧÀÍÆ÷¿éÉèÖá£
ÈôÊÇÄúÓöµ½ÎÊÌ⣬Çë¼ì²é Nginx ¹ýʧÈÕÖ¾ÒÔ»ñÈ¡¸ü¶àÐÅÏ¢¡£
ÒÔÉϾÍÊÇnginxÔõôÉèÖÃÏÔʾÓòÃûµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡