尊龙凯时人生就是搏

ÔõÑùʹÓÃNGINXºÍPM2ÓÅ»¯VPSЧÀÍÆ÷µÄÍøÂçÐÔÄÜ

ÔõÑùʹÓÃNGINXºÍPM2ÓÅ»¯VPSЧÀÍÆ÷µÄÍøÂçÐÔÄÜ

¼ò½é£º

ÔÚÔËÐÐÍøÕ¾»òÓ¦ÓóÌÐòʱ£¬Ð§ÀÍÆ÷µÄÍøÂçÐÔÄÜÊÇÖÁ¹ØÖ÷ÒªµÄ¡£ÎªÁËÌá¸ßЧÀÍÆ÷µÄÍøÂçÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔʹÓÃNGINXºÍPM2Á½¸öÇ¿Ê¢µÄ¹¤¾ßÀ´¾ÙÐÐÓÅ»¯¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNGINXºÍPM2À´ÓÅ»¯VPSЧÀÍÆ÷µÄÍøÂçÐÔÄÜ£¬²¢ÌṩһЩÏêϸµÄ´úÂëʾÀý¡£

Ò»¡¢×°ÖúÍÉèÖÃNGINX

×°ÖÃNGINX

ʹÓÃÒÔÏÂÏÂÁîÔÚVPSЧÀÍÆ÷ÉÏ×°ÖÃNGINX£º

sudo apt update
sudo apt install nginx

µÇ¼ºó¸´ÖÆ

ÉèÖÃNGINX

ÔÚ×°ÖÃÍê³Éºó£¬ÎÒÃÇÐèÒªÉèÖÃNGINXÒÔÌá¸ßЧÀÍÆ÷µÄÍøÂçÐÔÄÜ¡£·­¿ªNGINXµÄĬÈÏÉèÖÃÎļþ£º

sudo nano /etc/nginx/nginx.conf

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÔÚÉèÖÃÎļþÖоÙÐÐÒÔϸü¸Ä£º

ÔöÌíworker_processesÉèÖÃÀ´Ö¸¶¨NGINXʹÓõÄÀú³ÌÊýÄ¿£¬Ò»Ñùƽ³£ÉèÖÃΪCPU½¹µãÊýÄ¿µÄÁ½±¶£º

worker_processes auto;

µÇ¼ºó¸´ÖÆ

ÔöÌíworker_connectionsÉèÖÃÀ´Ö¸¶¨Ã¿¸öÊÂÇéÀú³ÌµÄ²¢·¢ÅþÁ¬Êý£¬ÒÔÖ§³Ö¸ü¶àµÄ²¢·¢ÇëÇó£º

events {
 worker_connections 2048;
}

µÇ¼ºó¸´ÖÆ

ÔöÌíkeepalive_timeoutÉèÖÃÀ´Ö¸¶¨ÔÚÒ»¸ö³¤ÆÚÅþÁ¬ÉÏÆÚ´ýÏÂÒ»¸öÇëÇóµÄʱ¼ä£º

http {
 keepalive_timeout 65;
}

µÇ¼ºó¸´ÖÆ

Íê³É¸ü¸Äºó£¬ÉúÑIJ¢Í˳öÉèÖÃÎļþ¡£ÖØмÓÔØNGINXÒÔʹ¸ü¸ÄÉúЧ£º

sudo systemctl reload nginx

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

¶þ¡¢Ê¹ÓÃNGINX¾ÙÐиºÔØƽºâ

×°Öò¢ÉèÖÃPM2

ʹÓÃÒÔÏÂÏÂÁîÔÚVPSЧÀÍÆ÷ÉÏ×°ÖÃPM2£º

sudo npm install pm2 -g

µÇ¼ºó¸´ÖÆ

Æô¶¯Ó¦ÓóÌÐò

Ê×ÏÈ£¬Ê¹ÓÃÒÔÏÂÏÂÁîÔÚPM2ÖÐÆô¶¯ÄãµÄÓ¦ÓóÌÐò£º

pm2 start app.js

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬app.jsÊÇÄãµÄÓ¦ÓóÌÐòµÄÈë¿ÚÎļþ¡£Äã¿ÉÒÔƾ֤ÄãµÄÏÖÕæÏàÐξÙÐÐÐ޸ġ£

ÉèÖÃNGINX·´ÏòÊðÀí

·­¿ªNGINXµÄĬÈÏÉèÖÃÎļþ£º

sudo nano /etc/nginx/nginx.conf

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

ÔÚhttp¿éÏ£¬Ìí¼ÓÒÔÏÂÉèÖÃÀ´ÉèÖ÷´ÏòÊðÀíºÍ¸ºÔØƽºâ£º

http {
 ...
 upstream backend {
     server 127.0.0.1:3000;
     server 127.0.0.1:3001;
 }
 
 server {
     listen 80;
     server_name your_domain.com;
     
     location / {
         proxy_pass http://backend;
         proxy_set_header Host $host;
         proxy_set_header X-Real-IP $remote_addr;
     }
 }
 ...
}

µÇ¼ºó¸´ÖÆ

ÉÏÊöÉèÖÃÖУ¬ÎÒÃǼÙÉèÓ¦ÓóÌÐòÔÚÍâµØµÄ3000ºÍ3001¶Ë¿ÚÉÏÔËÐС£Äã¿ÉÒÔƾ֤ÏÖÕæÏàÐξÙÐÐÐ޸ġ£

Íê³É¸ü¸Äºó£¬ÉúÑIJ¢Í˳öÉèÖÃÎļþ¡£ÖØмÓÔØNGINXÒÔʹ¸ü¸ÄÉúЧ£º

sudo systemctl reload nginx

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

×ܽ᣺

ͨ¹ý×°ÖúÍÉèÖÃNGINX¾ÙÐÐÓÅ»¯£¬ÎÒÃÇÌá¸ßÁËЧÀÍÆ÷µÄÍøÂçÐÔÄÜ¡£Ê¹ÓÃNGINX¾ÙÐиºÔØƽºâ£¬ÎÒÃÇ¿ÉÒÔ·Ö·¢ÇëÇ󵽶à¸öÓ¦ÓóÌÐòʵÀýÉÏ£¬´Ó¶øÌá¸ßЧÀÍÆ÷µÄ²¢·¢´¦ÀíÄÜÁ¦¡£ÔÚÖÖÖÖÓ¦ÓóÌÐòºÍ³¡¾°ÖУ¬ÕâЩÓÅ»¯¶¼¿ÉÒÔ×ÊÖúÎÒÃÇÌá¸ßЧÀÍÆ÷µÄÍøÂçÐÔÄÜ£¬Ìṩ¸üºÃµÄÓû§ÌåÑé¡£

ÒÔÉϾÍÊÇÔõÑùʹÓÃNGINXºÍPM2ÓÅ»¯VPSЧÀÍÆ÷µÄÍøÂçÐÔÄܵÄÏêϸҪÁìºÍ´úÂëʾÀý¡£Ï£Íû¶ÔÄãÓÐËù×ÊÖú£¡

ÒÔÉϾÍÊÇÔõÑùʹÓÃNGINXºÍPM2ÓÅ»¯VPSЧÀÍÆ÷µÄÍøÂçÐÔÄܵÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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