尊龙凯时人生就是搏

¸ß¼¶½Ì³Ì: ʹÓÃNGINXºÍPM2ÓÅ»¯VPSЧÀÍÆ÷µÄÐÔÄÜ

¸ß¼¶½Ì³Ì£ºÊ¹ÓÃNGINXºÍPM2ÓÅ»¯VPSЧÀÍÆ÷µÄÐÔÄÜ

ͻ񻣼

Ëæ×Å»¥ÁªÍøµÄÉú³¤ £¬Ô½À´Ô½¶àµÄÈËÑ¡Ôñ½«ÍøÕ¾°²ÅÅÔÚVPSЧÀÍÆ÷ÉÏ¡£È»¶ø £¬Ëæ×ÅÍøÕ¾Á÷Á¿µÄÔöÌí £¬Ð§ÀÍÆ÷ÐÔÄÜ¿ÉÄܳÉΪһ¸öÎÊÌâ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃNGINXºÍPM2À´ÓÅ»¯VPSЧÀÍÆ÷µÄÐÔÄÜ £¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£

СÐò£º

VPSЧÀÍÆ÷ÊÇÒ»ÖÖÏà¶Ô±¾Ç®½ÏµÍÇÒÎÞаµÄÑ¡Ôñ £¬Òò´ËÔÚÍøÕ¾°²ÅÅÖÐÔ½À´Ô½ÊܽӴý¡£È»¶ø £¬Ò»µ©ÍøÕ¾×îÏÈÎüÒý´ó×Ú»á¼ûÕß £¬Ð§ÀÍÆ÷ÐÔÄܵÄÓÅ»¯¾Í±äµÃºÜÊÇÖ÷Òª¡£ÔÚÕâÖÖÇéÐÎÏ £¬Ê¹ÓÃNGINXºÍPM2×éºÏÊÇÒ»ÖÖ³£¼ûµÄ½â¾ö¼Æ»®¡£NGINXÊÇÒ»¸ö¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷ £¬¶øPM2ÊÇÒ»¸öÇ¿Ê¢µÄÀú³ÌÖÎÀí¹¤¾ß¡£

°ì·¨Ò»£º×°ÖÃNGINX

Ê×ÏÈ £¬ÎÒÃÇÐèҪװÖÃNGINX¡£Ê¹ÓÃÒÔÏÂÏÂÁîÔÚUbuntuÉÏ×°ÖÃNGINX£º

$ sudo apt-get update
$ sudo apt-get install nginx

µÇ¼ºó¸´ÖÆ

×°ÖÃÍê³Éºó £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Æô¶¯NGINX£º

$ sudo systemctl start nginx

µÇ¼ºó¸´ÖÆ

°ì·¨¶þ£ºÉèÖÃNGINX

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒªÉèÖÃNGINXÒÔÌá¸ßÐÔÄÜ¡£·­¿ªNGINXÉèÖÃÎļþ²¢¾ÙÐÐÒÔϸü¸Ä£º

$ sudo nano /etc/nginx/nginx.conf

µÇ¼ºó¸´ÖÆ

ÕÒµ½ÒÔÏÂÐв¢×÷·Ï×¢ÊÍ£º

worker_processes auto;

µÇ¼ºó¸´ÖÆ

½«ÒÔϲÎÊý¸ü¸ÄΪÊʺÏÄúЧÀÍÆ÷µÄÖµ£º

worker_connections 4096;

µÇ¼ºó¸´ÖÆ

ÉúÑIJ¢¹Ø±ÕÎļþ¡£È»ºóÖØмÓÔØNGINXÉèÖãº

$ sudo systemctl reload nginx

µÇ¼ºó¸´ÖÆ

°ì·¨Èý£º×°ÖÃPM2

ÏÖÔÚ £¬ÎÒÃǽ«×°ÖúÍÉèÖÃPM2À´ÖÎÀíÎÒÃǵÄÓ¦ÓóÌÐò¡£Ê×ÏÈ £¬Ê¹ÓÃnpmÈ«¾Ö×°ÖÃPM2£º

$ sudo npm install pm2 -g

µÇ¼ºó¸´ÖÆ

Ò»µ©×°ÖÃÍê³É £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÆô¶¯Ò»¸öNode.jsÓ¦ÓóÌÐò£º

$ pm2 start app.js

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬app.jsÊÇÄúÒªÆô¶¯µÄNode.jsÓ¦ÓóÌÐòµÄÈë¿ÚÎļþ¡£Ê¹ÓÃÒÔÏÂÏÂÁîÀ´Éó²éÕýÔÚÔËÐеÄÓ¦ÓóÌÐò£º

$ pm2 list

µÇ¼ºó¸´ÖÆ

°ì·¨ËÄ£ºÉèÖÃPM2×Ô¶¯Æô¶¯

ΪÁËʹЧÀÍÖØÊÓÆôºóPM2×Ô¶¯Æô¶¯ÎÒÃǵÄÓ¦ÓóÌÐò £¬ÎÒÃÇÐèÒªÉèÖÃPM2×ÔÆô¶¯¾ç±¾¡£Ê¹ÓÃÒÔÏÂÏÂÁîÌìÉú×ÔÆô¶¯¾ç±¾£º

$ pm2 startup

µÇ¼ºó¸´ÖÆ

È»ºó £¬Æ¾Ö¤ÌáÐÑÖ´ÐÐÌìÉúµÄÏÂÁî¡£ÔËÐÐÍêºó £¬ÖØÆôЧÀÍÆ÷ÒÔÈ·ÈÏ×ÔÆô¶¯¾ç±¾ÊÇ·ñÕý³£ÊÂÇé¡£

½áÂÛ£º

ͨ¹ýʹÓÃNGINXºÍPM2 £¬ÎÒÃÇ¿ÉÒÔÓÐÓõØÓÅ»¯VPSЧÀÍÆ÷µÄÐÔÄÜ¡£NGINX×÷Ϊ·´ÏòÊðÀíЧÀÍÆ÷ £¬¿ÉÒÔÌṩ¸ßÐÔÄܵľ²Ì¬ÎļþЧÀÍ £¬²¢µ÷ÀíÇëÇóÒÔÌá¸ßÍøÕ¾µÄÏìÓ¦ÄÜÁ¦¡£PM2ÔòÊÇÒ»¸öÇ¿Ê¢µÄÀú³ÌÖÎÀí¹¤¾ß £¬¿ÉÒÔÈ·±£Ó¦ÓóÌÐòʼÖÕÔËÐÐ £¬²¢ÔÚЧÀÍÖØÊÓÆôºó×Ô¶¯Æô¶¯¡£Í¨¹ý×ñÕÕ±¾ÎÄÖеİ취 £¬²¢Æ¾Ö¤ÄúµÄÐèÇó¾ÙÐÐÏìÓ¦µÄµ÷½â £¬Äú½«Äܹ»ÎªÄúµÄVPSЧÀÍÆ÷Ìṩ¸üºÃµÄÐÔÄÜ¡£

¸½×¢£ºÒÔÏÂÊÇÒ»¸öÍêÕûµÄNGINXºÍPM2ÉèÖÃÎļþʾÀý £¬ÓÃÓÚÒ»¸öNode.jsÓ¦ÓóÌÐòµÄ·´ÏòÊðÀíºÍ¸ºÔØƽºâ£º

events {
  worker_connections  4096;
}

http {
  upstream app {
    server 127.0.0.1:3000;
    server 127.0.0.1:3001;
    server 127.0.0.1:3002;
  }

  server {
    listen 80;
    server_name example.com;

    location / {
      proxy_pass http://app;
      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;
    }
  }
}

µÇ¼ºó¸´ÖÆ

Çëƾ֤ÄúµÄЧÀÍÆ÷ºÍÓ¦ÓóÌÐòÐèÇó¾ÙÐÐÏìÓ¦µÄÐ޸ġ£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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