nginxÔõô´î½¨ÍøÕ¾
ʹÓà nginx ´î½¨ÍøÕ¾·ÖÎå²½¾ÙÐУºÒ»¡¢×°Öà nginx£»¶þ¡¢ÉèÖà nginx£¬Ö÷ÒªÉèÖüàÌý¶Ë¿Ú¡¢ÍøÕ¾¸ùĿ¼¡¢Ë÷ÒýÎļþºÍ¹ýʧҳÃ棻Èý¡¢½¨ÉèÍøÕ¾Îļþ£»ËÄ¡¢²âÊÔ nginx£»Îå¡¢¿Éƾ֤ÐèÒª¾ÙÐнø½×ÉèÖã¬Èç ssl ¼ÓÃÜ¡¢·´ÏòÊðÀí¡¢¸ºÔØƽºâ»ººÍ´æ¡£
ÔõÑùʹÓà Nginx ´î½¨ÍøÕ¾
Ò»¡¢×°ÖÃ Nginx
Linux/Unix ϵͳ£º
sudo apt-get update sudo apt-get install nginx
µÇ¼ºó¸´ÖÆ
Windows ϵͳ£º
ÏÂÔØ Nginx ×°ÖóÌÐò²¢ÔËÐС£
¶þ¡¢ÉèÖà Nginx
·¿ª Nginx ÉèÖÃÎļþ /etc/nginx/nginx.conf »ò C:\nginx\conf\nginx.conf¡£
ÔÚÉèÖÃÎļþÖÐÉèÖÃÒÔÏÂÄÚÈÝ£º
1. ¼àÌý¶Ë¿Ú£¨Ä¬È϶˿ÚΪ 80£©
listen 80;
µÇ¼ºó¸´ÖÆ
2. ½ç˵ÍøÕ¾¸ùĿ¼£¨ÀýÈ磺/var/www/html£©
root /var/www/html;
µÇ¼ºó¸´ÖÆ
3. Ö¸¶¨Ë÷ÒýÎļþ£¨Ä¬ÈÏֵΪ index.html£©
index index.html;
µÇ¼ºó¸´ÖÆ
4. ÉèÖùýʧҳÃ棨ÀýÈ磺404 Not Found£©
error_page 404 /404.html;
µÇ¼ºó¸´ÖÆ
Èý¡¢½¨ÉèÍøÕ¾Îļþ
ÔÚÖ¸¶¨µÄÍøÕ¾¸ùĿ¼£¨ÀýÈ磺/var/www/html£©Öн¨ÉèÄúµÄÍøÕ¾Îļþ¡£ÕâЩÎļþ¿ÉÒÔÊÇ HTML¡¢CSS¡¢JavaScript »òͼÏñÎļþ¡£
ËÄ¡¢²âÊÔ Nginx
ÉúÑÄ Nginx ÉèÖÃÎļþ²¢ÖØÐÂÆô¶¯Ð§ÀÍ£º
Linux/Unix ϵͳ£º
sudo systemctl restart nginx
µÇ¼ºó¸´ÖÆ
Windows ϵͳ£º
ÓÒ¼üµ¥»÷ Nginx ÍÐÅÌͼ±ê²¢Ñ¡Ôñ¡°ÖØÐÂÆô¶¯¡±
ÔÚä¯ÀÀÆ÷Öлá¼ûÄúµÄÍøÕ¾ÓòÃû»ò IP µØµã£¬ÒÔÉó²éÍøÕ¾ÊÇ·ñÕý³£ÔËÐС£
Îå¡¢½ø½×ÉèÖÃ
SSL ¼ÓÃÜ£ºÊ¹Óà Let’s Encrypt Ö¤ÊéÉèÖà HTTPS¡£
·´ÏòÊðÀí£º½«ÇëÇóת·¢µ½ÆäËûЧÀÍÆ÷¡£
¸ºÔØƽºâ£ºÔÚ¶à¸öЧÀÍÆ÷ÉÏ·Ö·¢Á÷Á¿¡£
»º´æ£º´æ´¢ÆµÈÔÇëÇóµÄÄÚÈÝ£¬ÒÔÌá¸ßÐÔÄÜ¡£
ÒÔÉϾÍÊÇnginxÔõô´î½¨ÍøÕ¾µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡