尊龙凯时人生就是博

¼òÃ÷½Ì³Ì: ÔõÑùÔÚVPSÉÏʹÓÃNGINXºÍPM2Ìá¸ßÍøÕ¾ÐÔÄÜ

¼òÃ÷½Ì³Ì£ºÔõÑùÔÚVPSÉÏʹÓÃNGINXºÍPM2Ìá¸ßÍøÕ¾ÐÔÄÜ

СÐò£º

ÔÚÏÖ´úÍøÂçÇéÐÎÖÐ £¬¸ßÐÔÄܵÄÍøÕ¾ÒѾ­³ÉΪÁËÓû§µÄ×·ÇóÄ¿µÄ¡£ÎªÁËÌṩ¸üºÃµÄÓû§ÌåÑéºÍÏìÓ¦ËÙÂÊ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýʹÓÃNGINXºÍPM2À´ÓÅ»¯ÍøÕ¾ÐÔÄÜ¡£±¾ÎĽ«ÏêϸÏÈÈÝÔõÑùÔÚVPSÉÏÉèÖÃNGINXºÍPM2 £¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£

×°ÖúÍÉèÖÃNGINX

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚVPSÉÏ×°ÖÃNGINX¡£Ò»Ñùƽ³£À´Ëµ £¬¿ÉÒÔͨ¹ý°ü¹ÜÀí¹¤¾ß£¨Èçapt¡¢yumµÈ£©À´¾ÙÐÐ×°Öá£ÒÔÏÂÊÇÔÚUbuntuϵͳÉÏ×°ÖÃNGINXµÄÏÂÁîʾÀý£º

sudo apt update
sudo apt install nginx

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó £¬ÎÒÃÇÐèÒª¶ÔNGINX¾ÙÐÐһЩ»ù±¾µÄÉèÖá£Ö÷Òª°üÀ¨¼àÌý¶Ë¿Ú¡¢ÓòÃû°ó¶¨ÒÔ¼°·´ÏòÊðÀíµÈ¡£ÒÔÏÂÊÇÒ»¸öʾÀýµÄNGINXÉèÖÃÎļþ£º

server {
 listen 80;
 server_name your_domain.com;

 location / {
     proxy_pass http://localhost:3000;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection 'upgrade';
     proxy_set_header Host $host;
     proxy_cache_bypass $http_upgrade;
 }
}

µÇ¼ºó¸´ÖÆ

Õâ¸öÉèÖÃÎļþ¼ÙÉèÄãµÄÍøÕ¾ÔËÐÐÔÚÍâµØµÄ3000¶Ë¿ÚÉÏ¡£ÄãÐèÒª½«”your_domain.com”Ì滻ΪÄãµÄÓòÃû £¬²¢½«ÉèÖÃÎļþÉúÑĵ½”/etc/nginx/conf.d/your_domain.conf”Ŀ¼Ï¡£ÉèÖÃÍê³Éºó £¬ÖØÆôNGINXЧÀÍʹÉèÖÃÉúЧ¡£

×°ÖúÍÉèÖÃPM2

½ÓÏÂÀ´ £¬ÎÒÃǽ«Ê¹ÓÃPM2À´ÖÎÀíÍøÕ¾µÄÀú³Ì¡£PM2¿ÉÒÔ×ÊÖúÎÒÃǼà¿Ø¡¢×Ô¶¯ÖØÆôºÍ¸ºÔØƽºâÍøÕ¾µÄÀú³Ì¡£ÒÔÏÂÊÇÔÚVPSÉÏ×°ÖÃPM2µÄÏÂÁîʾÀý£º

sudo npm install -g pm2

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó £¬Ê¹ÓÃÒÔÏÂÏÂÁîÀ´Æô¶¯Ò»¸öÍøÕ¾µÄÀú³Ì£º

pm2 start your_script.js

µÇ¼ºó¸´ÖÆ

Õâ¸öÏÂÁî»áÆô¶¯Ò»¸öÃûΪ”your_script.js”µÄÍøÕ¾Àú³Ì¡£ÄãÐèÒª½«¸ÃÏÂÁîµ÷½âΪ˳ӦÄãµÄ¾ç±¾Îļþ·¾¶ºÍÏÂÁî¡£

ʹÓÃPM2µÄ¸ºÔØƽºâ¹¦Ð§

ΪÁ˽øÒ»²½Ìá¸ßÍøÕ¾µÄÐÔÄÜ £¬ÎÒÃÇ¿ÉÒÔʹÓÃPM2µÄ¸ºÔØƽºâ¹¦Ð§¡£¸ºÔØƽºâ¿ÉÒÔ½«ÇëÇó·Ö·¢µ½¶à¸öÍøÕ¾Àú³ÌÉÏ £¬ÒÔÌṩ¸ü¸ßµÄ²¢·¢´¦ÀíÄÜÁ¦¡£ÒÔÏÂÊÇÒ»¸öʹÓÃPM2¸ºÔØƽºâµÄʾÀý£º

pm2 start your_script.js -i max

µÇ¼ºó¸´ÖÆ

Õâ¸öÏÂÁÆô¶¯¶à¸öÍøÕ¾Àú³Ì £¬ÆäÖД-i max”²ÎÊýÌåÏÖʹÓÃ×î´óÊýÄ¿µÄÀú³Ì¡£PM2»áƾ֤ЧÀÍÆ÷µÄCPU½¹µãÊýÄ¿×Ô¶¯µ÷½âÀú³ÌÊýÄ¿¡£

¼à¿ØºÍÖÎÀíÍøÕ¾Àú³Ì

PM2ÌṩÁËһЩÏÂÁîÀ´¼à¿ØºÍÖÎÀíÍøÕ¾Àú³Ì¡£ÒÔÏÂÊÇһЩ³£ÓõÄÏÂÁîʾÀý£º

¼à¿ØÍøÕ¾Àú³ÌµÄ״̬£ºpm2 status

¼à¿ØÍøÕ¾Àú³ÌµÄ×ÊԴʹÓÃÇéÐΣºpm2 monit

×èÖ¹Ò»¸öÍøÕ¾Àú³Ì£ºpm2 stop your_script.js

ÖØÆôÒ»¸öÍøÕ¾Àú³Ì£ºpm2 restart your_script.js

×ܽ᣺

ͨ¹ýʹÓÃNGINXºÍPM2 £¬ÎÒÃÇ¿ÉÒÔÔÚVPSÉÏÓÅ»¯ÍøÕ¾µÄÐÔÄÜ¡£NGINX¿ÉÒÔ×÷Ϊ·´ÏòÊðÀíЧÀÍÆ÷ £¬Í¨¹ýÉèÖ÷´ÏòÊðÀíÀ´Ìá¸ßÍøÕ¾µÄÏìÓ¦ËÙÂÊ¡£PM2¿ÉÒÔ×ÊÖúÎÒÃÇÖÎÀíºÍ¼à¿ØÍøÕ¾µÄÀú³Ì £¬²¢Í¨¹ý¸ºÔØƽºâÀ´Ìṩ¸üºÃµÄ²¢·¢´¦ÀíÄÜÁ¦¡£Ï£Íû±¾ÎĹØÓÚÐèÒªÔÚVPSÉÏÌá¸ßÍøÕ¾ÐÔÄܵĿª·¢ÕßÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊǼòÃ÷½Ì³Ì: ÔõÑùÔÚVPSÉÏʹÓÃNGINXºÍPM2Ìá¸ßÍøÕ¾ÐÔÄܵÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

13452372176

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

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

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