nginxÔõô°²ÅÅjar³ÌÐò
ΪÔÚ nginx ÉÏ°²ÅÅ jar ³ÌÐò£¬ÐèÒª×ñÕÕÆ߸ö°ì·¨£º1) ×°Öà jre£¬2) ×°Öà nginx£¬3) ÉèÖà nginx£¬4) °²ÅÅ jar£¬5) ÊÚÓèÖ´ÐÐȨÏÞ£¬6) ÖØÆô nginx£¬7) ÑéÖ¤°²ÅÅ¡£
Nginx °²ÅÅ JAR ³ÌÐò
Ϊ Java Web Ó¦ÓóÌÐò°²ÅÅ JAR ³ÌÐòµ½ Nginx ЧÀÍÆ÷ÐèÒªÒÔÏ°취£º
1. ×°ÖÃ Java Runtime Environment (JRE)
ÔÚЧÀÍÆ÷ÉÏ×°Öà JRE£¬ÕâÊÇÔËÐÐ Java ³ÌÐòËùÐèµÄÈí¼þÇéÐΡ£
2. ×°ÖÃ nginx
ÔÚЧÀÍÆ÷ÉÏ×°Öà Nginx Web ЧÀÍÆ÷£¬ËüÊÇ´¦Àí Web ÇëÇóµÄÈí¼þ¡£
3. ÉèÖÃ nginx
ÔÚ Nginx ÉèÖÃÎļþÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£¬Ö¸Ê¾ Nginx ÈçÄÇÀïÖà JAR Îļþ£º
location /myapp { proxy_pass http://localhost:8080; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; }
µÇ¼ºó¸´ÖÆ
Ìæ»» localhost:8080 ΪÏÖʵµÄ Java Web Ó¦ÓóÌÐò¶Ë¿Ú¡£
4. °²ÅÅ JAR Îļþ
½« JAR Îļþ¸´ÖƵ½ Nginx Web ЧÀÍÆ÷µÄÖ¸¶¨Ä¿Â¼£¬ÀýÈç /usr/share/nginx/html/myapp/myapp.jar¡£
5. ÊÚÓèÖ´ÐÐȨÏÞ
ÊÚÓè JAR ÎļþÖ´ÐÐȨÏÞ£¬ÒÔ±ã Nginx Äܹ»Æô¶¯Ó¦ÓóÌÐò£º
chmod +x /usr/share/nginx/html/myapp/myapp.jar
µÇ¼ºó¸´ÖÆ
6. ÖØÆô Nginx
ÖØÆô Nginx ÒÔÓ¦Óøü¸ÄµÄÉèÖãº
systemctl restart nginx
µÇ¼ºó¸´ÖÆ
7. ÑéÖ¤°²ÅÅ
ʹÓà Web ä¯ÀÀÆ÷»á¼ûÓ¦ÓóÌÐòµÄ URL£¨ÀýÈç https://your-domain/myapp£©¡£ÈôÊÇÓ¦ÓóÌÐòÕý³£ÔËÐУ¬Ôò°²ÅÅÀֳɡ£
ÒÔÉϾÍÊÇnginxÔõô°²ÅÅjar³ÌÐòµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡