Ôõôȥµônginx½Ó´ýÒ³Ãæ
¿ÉÒƳý nginx ½Ó´ýÒ³Ã棬°ì·¨ÈçÏ£º±à¼ÉèÖÃÎļþ£¨/etc/nginx/nginx.conf£©×¢ÊÍ location / ÖÐµÄ return ÐÐÉúÑIJ¢ÖØÆô nginx (sudo systemctl restart nginx)
ÔõÑùÒƳý Nginx ½Ó´ýÒ³Ãæ
Nginx ½Ó´ýÒ³ÃæÊÇÒ»¸ö¼òÆ HTML Ò³Ã棬ËüÔÚÊ״λá¼û Nginx ÍйܵÄÍøվʱÏÔʾÔÚä¯ÀÀÆ÷ÖС£Ëüͨ³£°üÀ¨ Nginx »Õ±êºÍ°æ±¾ºÅ¡£ÔÚijЩÇéÐÎÏ£¬Äú¿ÉÄÜÐèÒªÒƳý½Ó´ýÒ³Ã棬ÀýÈçÔÚ°²ÅÅ×Ô½ç˵ÍøÕ¾»òÓ¦ÓóÌÐòʱ¡£
ÒƳý Nginx ½Ó´ýÒ³ÃæµÄ°ì·¨£º
1. ±à¼ Nginx ÉèÖÃÎļþ
ʹÓÃÎı¾±à¼Æ÷·¿ª Nginx ÉèÖÃÎļþ£¬Í¨³£Î»ÓÚ /etc/nginx/nginx.conf¡£
2. ¶¨Î»²¢×¢ÊͽӴýÒ³ÃæÉèÖÃ
ÔÚÉèÖÃÎļþÖУ¬ÕÒµ½ÒÔϲ¿·Ö£º
server { listen 80; server_name example.com; location / { return 200 "Welcome to Nginx!"; } }
µÇ¼ºó¸´ÖÆ
ÔÚ location / ¿éÖУ¬×¢Ê͵ôÒÔÏÂÐУº
return 200 "Welcome to Nginx!";
µÇ¼ºó¸´ÖÆ
ÕâÑù»á×¢Ê͵ô½Ó´ýÒ³ÃæÖ¸Áî¡£
3. ÉúÑIJ¢ÖØÐÂÆô¶¯ Nginx
ÉúÑÄÉèÖÃÎļþ²¢ÖØÐÂÆô¶¯ Nginx£º
sudo systemctl restart nginx
µÇ¼ºó¸´ÖÆ
4. ÑéÖ¤ÒƳý
»á¼ûÄúµÄÍøÕ¾£¬½Ó´ýÒ³ÃæÓ¦¸ÃÒÑÏûÊÅ¡£
×¢ÖØÊÂÏ
- ÈôÊÇÄúÓжà¸öЧÀÍÆ÷¿é£¬ÇëÈ·±£¶ÔËùÓÐЧÀÍÆ÷¿éÖ´Ðд˲Ù×÷¡£
- ½Ó´ýÒ³Ãæ½öÔÚÊ״λá¼ûʱÏÔʾ¡£ÈôÊÇÄúÒÑ»á¼û¹ý¸ÃÍøÕ¾£¬Ôò²»»áÔٴο´µ½½Ó´ýÒ³Ã棬×ÝȻ佫ÆäÒƳý¡£
- ½¨ÒéÔÚÒƳý½Ó´ýÒ³Ãæ֮ǰ½¨×°±¸·Ý¡£
ÒÔÉϾÍÊÇÔõôȥµônginx½Ó´ýÒ³ÃæµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡