{"id":63530,"date":"2025-04-29T10:36:35","date_gmt":"2025-04-29T02:36:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63530\/"},"modified":"2025-04-29T10:36:35","modified_gmt":"2025-04-29T02:36:35","slug":"nginx%e6%80%8e%e4%b9%88%e9%83%a8%e7%bd%b2jar%e7%a8%8b%e5%ba%8f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63530\/","title":{"rendered":"nginx\u600e\u4e48\u90e8\u7f72jar\u7a0b\u5e8f"},"content":{"rendered":"<blockquote><p>\n  \u4e3a\u5728 nginx \u4e0a\u90e8\u7f72 jar \u7a0b\u5e8f\uff0c\u9700\u8981\u9075\u5faa\u4e03\u4e2a\u6b65\u9aa4\uff1a1) \u5b89\u88c5 jre\uff0c2) \u5b89\u88c5 nginx\uff0c3) \u914d\u7f6e nginx\uff0c4) \u90e8\u7f72 jar\uff0c5) \u6388\u4e88\u6267\u884c\u6743\u9650\uff0c6) \u91cd\u542f nginx\uff0c7) \u9a8c\u8bc1\u90e8\u7f72\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052718271769139.jpg\" class=\"aligncenter\" title=\"nginx\u600e\u4e48\u90e8\u7f72jar\u7a0b\u5e8f\u63d2\u56fe\" alt=\"nginx\u600e\u4e48\u90e8\u7f72jar\u7a0b\u5e8f\u63d2\u56fe\" \/><\/p>\n<p><strong>Nginx \u90e8\u7f72 JAR \u7a0b\u5e8f<\/strong><\/p>\n<p>\u4e3a Java Web \u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72 JAR \u7a0b\u5e8f\u5230 Nginx \u670d\u52a1\u5668\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u5b89\u88c5 Java Runtime Environment (JRE)<\/strong><\/p>\n<ul>\n<li>\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 JRE\uff0c\u8fd9\u662f\u8fd0\u884c Java \u7a0b\u5e8f\u6240\u9700\u7684\u8f6f\u4ef6\u73af\u5883\u3002<\/li>\n<\/ul>\n<p><strong>2. \u5b89\u88c5 <\/strong><\/p>\n<ul>\n<li>\u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 Nginx Web \u670d\u52a1\u5668\uff0c\u5b83\u662f\u5904\u7406 Web \u8bf7\u6c42\u7684\u8f6f\u4ef6\u3002<\/li>\n<\/ul>\n<p><strong>3. \u914d\u7f6e nginx<\/strong><\/p>\n<ul>\n<li>\u5728 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff0c\u6307\u793a Nginx \u5982\u4f55\u5904\u7406 JAR \u6587\u4ef6\uff1a<\/li>\n<\/ul>\n<pre>location \/myapp {\n    proxy_pass http:\/\/localhost:8080;\n    proxy_set_header Host $host;\n    proxy_set_header X-Real-IP $remote_addr;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n<li>\u66ff\u6362 localhost:8080 \u4e3a\u5b9e\u9645\u7684 Java Web \u5e94\u7528\u7a0b\u5e8f\u7aef\u53e3\u3002<\/li>\n<\/ul>\n<p><strong>4. \u90e8\u7f72 JAR \u6587\u4ef6<\/strong><\/p>\n<ul>\n<li>\u5c06 JAR \u6587\u4ef6\u590d\u5236\u5230 Nginx Web \u670d\u52a1\u5668\u7684\u6307\u5b9a\u76ee\u5f55\uff0c\u4f8b\u5982 \/usr\/share\/nginx\/html\/myapp\/myapp.jar\u3002<\/li>\n<\/ul>\n<p><strong>5. \u6388\u4e88\u6267\u884c\u6743\u9650<\/strong><\/p>\n<ul>\n<li>\u6388\u4e88 JAR \u6587\u4ef6\u6267\u884c\u6743\u9650\uff0c\u4ee5\u4fbf Nginx \u80fd\u591f\u542f\u52a8\u5e94\u7528\u7a0b\u5e8f\uff1a<\/li>\n<\/ul>\n<pre>chmod +x \/usr\/share\/nginx\/html\/myapp\/myapp.jar<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>6. \u91cd\u542f Nginx<\/strong><\/p>\n<ul>\n<li>\u91cd\u542f Nginx \u4ee5\u5e94\u7528\u66f4\u6539\u7684\u914d\u7f6e\uff1a<\/li>\n<\/ul>\n<pre>systemctl restart nginx<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>7. \u9a8c\u8bc1\u90e8\u7f72<\/strong><\/p>\n<ul>\n<li>\u4f7f\u7528 Web \u6d4f\u89c8\u5668\u8bbf\u95ee\u5e94\u7528\u7a0b\u5e8f\u7684 URL\uff08\u4f8b\u5982 https:\/\/your-domain\/myapp\uff09\u3002\u5982\u679c\u5e94\u7528\u7a0b\u5e8f\u6b63\u5e38\u8fd0\u884c\uff0c\u5219\u90e8\u7f72\u6210\u529f\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u90e8\u7f72jar\u7a0b\u5e8f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u5728 nginx \u4e0a\u90e8\u7f72 jar \u7a0b\u5e8f\uff0c\u9700\u8981\u9075\u5faa\u4e03\u4e2a\u6b65\u9aa4\uff1a1) \u5b89\u88c5 jre\uff0c2) \u5b89\u88c5 nginx\uff0c3) \u914d\u7f6e nginx\uff0c4) \u90e8\u7f72 jar\uff0c5) \u6388\u4e88\u6267\u884c\u6743\u9650\uff0c6) \u91cd\u542f nginx\uff0c7) \u9a8c\u8bc1\u90e8\u7f72\u3002 Nginx \u90e8\u7f72 JAR \u7a0b\u5e8f \u4e3a Java Web \u5e94\u7528\u7a0b\u5e8f\u90e8\u7f72 JAR \u7a0b\u5e8f\u5230 Nginx \u670d\u52a1\u5668\u9700\u8981\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u5b89\u88c5 Java Runtime Environment (JRE) \u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 JRE\uff0c\u8fd9\u662f\u8fd0\u884c Java \u7a0b\u5e8f\u6240\u9700\u7684\u8f6f\u4ef6\u73af\u5883\u3002 2. \u5b89\u88c5 \u5728\u670d\u52a1\u5668\u4e0a\u5b89\u88c5 Nginx Web \u670d\u52a1\u5668\uff0c\u5b83\u662f\u5904\u7406 Web \u8bf7\u6c42\u7684\u8f6f\u4ef6\u3002 3. \u914d\u7f6e nginx \u5728 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff0c\u6307\u793a Nginx \u5982\u4f55\u5904\u7406 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63530","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63530"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63530\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}