{"id":42618,"date":"2024-10-03T20:47:09","date_gmt":"2024-10-03T12:47:09","guid":{"rendered":"https:\/\/server.hk\/cnblog\/42618\/"},"modified":"2024-10-03T20:47:09","modified_gmt":"2024-10-03T12:47:09","slug":"centos-6-7-%e4%b8%8b-nginxtomcat-%e7%b0%a1%e5%96%ae%e9%85%8d%e7%bd%ae%e5%8f%8a%e6%95%b4%e5%90%88","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/42618\/","title":{"rendered":"CentOS 6.7 \u4e0b Nginx+Tomcat \u7c21\u55ae\u914d\u7f6e\u53ca\u6574\u5408"},"content":{"rendered":"<h1 id=\"centos-6-7-%e4%b8%8b-nginxtomcat-%e7%b0%a1%e5%96%ae%e9%85%8d%e7%bd%ae%e5%8f%8a%e6%95%b4%e5%90%88-ZNRwWvHHZL\">CentOS 6.7 \u4e0b Nginx+Tomcat \u7c21\u55ae\u914d\u7f6e\u53ca\u6574\u5408<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0cNginx \u548c Tomcat \u662f\u5169\u500b\u975e\u5e38\u6d41\u884c\u7684\u4f3a\u670d\u5668\u8edf\u4ef6\u3002Nginx \u4ee5\u5176\u9ad8\u6548\u7684\u975c\u614b\u6587\u4ef6\u8655\u7406\u548c\u53cd\u5411\u4ee3\u7406\u529f\u80fd\u800c\u805e\u540d\uff0c\u800c Tomcat \u5247\u662f Java \u61c9\u7528\u7684\u9996\u9078\u4f3a\u670d\u5668\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u5982\u4f55\u5728 CentOS 6.7 \u4e0a\u7c21\u55ae\u914d\u7f6e\u548c\u6574\u5408 Nginx \u548c Tomcat\u3002<\/p>\n<h2 id=\"%e7%92%b0%e5%a2%83%e6%ba%96%e5%82%99-ZNRwWvHHZL\">\u74b0\u5883\u6e96\u5099<\/h2>\n<p>\u5728\u958b\u59cb\u4e4b\u524d\uff0c\u78ba\u4fdd\u4f60\u7684 CentOS 6.7 \u7cfb\u7d71\u5df2\u7d93\u66f4\u65b0\u5230\u6700\u65b0\u7248\u672c\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u9032\u884c\u66f4\u65b0\uff1a<\/p>\n<pre><code>sudo yum update<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u5b89\u88dd\u5fc5\u8981\u7684\u8edf\u4ef6\u5305\uff0c\u5305\u62ec Nginx \u548c Tomcat\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-nginx-ZNRwWvHHZL\">\u5b89\u88dd Nginx<\/h2>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88dd Nginx\uff1a<\/p>\n<pre><code>sudo yum install epel-release<\/code><\/pre>\n<pre><code>sudo yum install nginx<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u555f\u52d5 Nginx\uff1a<\/p>\n<pre><code>sudo service nginx start<\/code><\/pre>\n<p>\u70ba\u4e86\u78ba\u4fdd Nginx \u5728\u7cfb\u7d71\u555f\u52d5\u6642\u81ea\u52d5\u555f\u52d5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>sudo chkconfig nginx on<\/code><\/pre>\n<h2 id=\"%e5%ae%89%e8%a3%9d-tomcat-ZNRwWvHHZL\">\u5b89\u88dd Tomcat<\/h2>\n<p>\u63a5\u4e0b\u4f86\uff0c\u6211\u5011\u5c07\u5b89\u88dd Tomcat\u3002\u9996\u5148\uff0c\u4e0b\u8f09 Tomcat \u7684\u6700\u65b0\u7248\u672c\uff1a<\/p>\n<pre><code>wget https:\/\/downloads.apache.org\/tomcat\/tomcat-8\/v8.5.73\/bin\/apache-tomcat-8.5.73.tar.gz<\/code><\/pre>\n<p>\u7136\u5f8c\u89e3\u58d3\u7e2e\u4e0b\u8f09\u7684\u6587\u4ef6\uff1a<\/p>\n<pre><code>tar -zxvf apache-tomcat-8.5.73.tar.gz<\/code><\/pre>\n<p>\u5c07\u89e3\u58d3\u7e2e\u7684\u6587\u4ef6\u593e\u79fb\u52d5\u5230 \/opt \u76ee\u9304\u4e0b\uff1a<\/p>\n<pre><code>sudo mv apache-tomcat-8.5.73 \/opt\/tomcat<\/code><\/pre>\n<p>\u63a5\u4e0b\u4f86\uff0c\u555f\u52d5 Tomcat\uff1a<\/p>\n<pre><code>cd \/opt\/tomcat\/bin<\/code><\/pre>\n<pre><code>sudo .\/startup.sh<\/code><\/pre>\n<h2 id=\"%e9%85%8d%e7%bd%ae-nginx-%e4%bd%9c%e7%82%ba%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86-ZNRwWvHHZL\">\u914d\u7f6e Nginx \u4f5c\u70ba\u53cd\u5411\u4ee3\u7406<\/h2>\n<p>\u73fe\u5728\uff0c\u6211\u5011\u9700\u8981\u914d\u7f6e Nginx \u4ee5\u4fbf\u5c07\u8acb\u6c42\u8f49\u767c\u5230 Tomcat\u3002\u7de8\u8f2f Nginx \u7684\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n<pre><code>sudo vi \/etc\/nginx\/nginx.conf<\/code><\/pre>\n<p>\u5728 server \u5340\u584a\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<pre><code>location \/ {\n    proxy_pass http:\/\/localhost:8080;\n    proxy_set_header Host $host;\n    proxy_set_header X-Real-IP $remote_addr;\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n    proxy_set_header X-Forwarded-Proto $scheme;\n}<\/code><\/pre>\n<p>\u9019\u6bb5\u914d\u7f6e\u5c07\u6240\u6709\u4f86\u81ea Nginx \u7684\u8acb\u6c42\u8f49\u767c\u5230 Tomcat \u7684 8080 \u7aef\u53e3\u3002<\/p>\n<h2 id=\"%e9%87%8d%e5%95%9f-nginx-ZNRwWvHHZL\">\u91cd\u555f Nginx<\/h2>\n<p>\u5b8c\u6210\u914d\u7f6e\u5f8c\uff0c\u91cd\u555f Nginx \u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n<pre><code>sudo service nginx restart<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e9%85%8d%e7%bd%ae-ZNRwWvHHZL\">\u6e2c\u8a66\u914d\u7f6e<\/h2>\n<p>\u5728\u700f\u89bd\u5668\u4e2d\u8f38\u5165\u4f60\u7684\u4f3a\u670d\u5668 IP \u5730\u5740\uff0c\u61c9\u8a72\u80fd\u5920\u770b\u5230 Tomcat \u7684\u6b61\u8fce\u9801\u9762\uff0c\u9019\u8868\u793a Nginx \u548c Tomcat \u7684\u6574\u5408\u6210\u529f\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-ZNRwWvHHZL\">\u7e3d\u7d50<\/h2>\n<p>\u5728 CentOS 6.7 \u4e0a\u914d\u7f6e Nginx \u548c Tomcat \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\u3002\u901a\u904e\u9019\u7a2e\u6574\u5408\uff0c\u4f60\u53ef\u4ee5\u5145\u5206\u5229\u7528 Nginx \u7684\u9ad8\u6548\u6027\u80fd\u548c Tomcat \u7684 Java \u61c9\u7528\u652f\u6301\u3002\u9019\u7a2e\u67b6\u69cb\u4e0d\u50c5\u80fd\u63d0\u9ad8\u7db2\u7ad9\u7684\u6027\u80fd\uff0c\u9084\u80fd\u589e\u5f37\u5b89\u5168\u6027\u3002<\/p>\n<p>\u5982\u679c\u4f60\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u9069\u5408\u5404\u7a2e\u9700\u6c42\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u9084\u662f\u5176\u4ed6\u985e\u578b\u7684 <a href=\"https:\/\/server.hk\">\u4f3a\u670d\u5668<\/a>\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u4f60\u63d0\u4f9b\u7a69\u5b9a\u7684\u670d\u52d9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to easily configure and integrate Nginx with Tomcat on CentOS 6.7 for efficient web server management and improved performance.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-42618","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=42618"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42618\/revisions"}],"predecessor-version":[{"id":42619,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/42618\/revisions\/42619"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=42618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=42618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=42618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}