{"id":107,"date":"2012-09-22T20:12:47","date_gmt":"2012-09-22T12:12:47","guid":{"rendered":"https:\/\/blog.indeex.club\/?p=107"},"modified":"2020-06-20T22:55:44","modified_gmt":"2020-06-20T14:55:44","slug":"%e5%8f%8d%e4%bb%a3%e7%90%86","status":"publish","type":"post","link":"https:\/\/blog.indeex.club\/index.php\/2012\/09\/22\/%e5%8f%8d%e4%bb%a3%e7%90%86\/","title":{"rendered":"\u53cd\u4ee3\u7406"},"content":{"rendered":"<hr \/>\n<p>\u3000\u3000\u3000\u3000\u3000<img src=\"http:\/\/hungking.cc\/assets\/imgs\/indeex.cc\/nginx.jpg\" alt=\"\u53cd\u4ee3\u7406\" \/><\/p>\n<hr \/>\n<p>\u7531\u4e8eWEB\u5f00\u53d1\u7684\u5b89\u5168\u6027\u95ee\u9898\uff0c\u5f80\u5f80\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u65f6\u5019\u9700\u8981\u9a8c\u8bc1\u8eab\u4efd\uff0c\u800c\u6709\u4e9b\u8d44\u6e90\u662f\u4e0d\u9700\u8981\u9a8c\u8bc1\u8eab\u4efd\u7684\uff0c\u6bd4\u5982\u516c\u5171\u8d44\u6e90\uff0c\u8fd9\u65f6\u6700\u5e38\u7528\u7684\u505a\u6cd5\u5c31\u662f\u5f00\u653e\u670d\u52a1\u5668\u6743\u9650\uff0c\u4ee5\u5141\u8bb8\u6240\u6709\u8bbf\u95ee\u8005\u90fd\u80fd\u8bbf\u95ee\u5230\u8d44\u6e90\u3002<\/p>\n<p>\u5bf9\u4e8e\u6bd4\u8f83\u654f\u611f\u7684\u8d44\u6e90\u4e00\u822c\u90fd\u4e0d\u5141\u8bb8\u8bbf\u95ee\uff0c\u6216\u8005\u9700\u8981\u9a8c\u8bc1\u5c5e\u4e8e\u540c\u6e90\u624d\u80fd\u8bbf\u95ee\u3002\u53cd\u4ee3\u7406\u5c31\u662f\u53bb\u8bbf\u95ee\u4e00\u4e9b\u7981\u6b62\u8de8\u57df\u7684\u8d44\u6e90\u3002<\/p>\n<p>\u9700\u8981\u8f6f\u4ef6\uff1a<\/p>\n<h2><center style='color:Blue'> NGINX<\/center><\/h2>\n<h3>1. \u4ecb\u7ecd<\/h3>\n<p>\u5173\u4e8e\u4ecb\u7ecd\uff1a<br \/>\n\u767e\u5ea6\u767e\u79d1\uff1a<a class=\"wp-editor-md-post-content-link\" href=\"https:\/\/baike.baidu.com\/item\/nginx\">nginx<\/a><\/p>\n<h3>2. \u4e0b\u8f7d<\/h3>\n<p>\u5b98\u65b9\u4e0b\u8f7d\u5730\u5740\uff1a<a class=\"wp-editor-md-post-content-link\" href=\"http:\/\/nginx.org\/en\/download.html\">\u4e0b\u8f7d\u5730\u5740<\/a><\/p>\n<h3>3. \u5b89\u88c5<\/h3>\n<p>\u7565.<\/p>\n<p><em>\u5b89\u88c5\u5b8c\u6210\u540e\u5148\u4e0d\u8981\u6253\u5f00\u670d\u52a1<\/em><\/p>\n<h3>4. \u4fee\u6539\u81ea\u5df1\u7684\u670d\u52a1\u5668\u5730\u5740<\/h3>\n<ol>\n<li>CD\u5230\u8f6f\u4ef6\u5b89\u88c5\u6839\u76ee\u5f55\/conf\/\u4e0b\uff0c\u6253\u5f00<strong>nginx.conf<\/strong>\u6587\u4ef6\u3002<\/p>\n<\/li>\n<li>\n<p>\u5c06listen\u7aef\u53e3\u4fee\u6539\u4e3a\u81ea\u5df1\u7684\u7aef\u53e3<\/p>\n<\/li>\n<li>\n<p>\u5c06server_name\u4fee\u6539\u4e3a\u81ea\u5df1\u7684\u670d\u52a1\u5668\u5730\u5740<\/p>\n<\/li>\n<li>\n<p>\u5c06server\u4e0b\u7684location\u4e0b\u7684\u9ed8\u8ba4\u5165\u53e3\u4fee\u6539\u4e3a\u81ea\u5df1\u7684\u670d\u52a1\u5668\u5165\u53e3\uff1a<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"line-numbers\">proxy_pass http:\/\/localhost:8090;\nproxy_redirect default;\n<\/code><\/pre>\n<h3>5. \u4fee\u6539\u9700\u8981\u8bbf\u95ee\u7684\u670d\u52a1\u5668\u5730\u5740<\/h3>\n<p>\u5728server\u4e0b\u589e\u52a0\u4e00\u4e2a\u6307\u5411\u670d\u52a1\u5668\u5730\u5740\u7684\u8def\u5f84\uff1a<\/p>\n<pre><code class=\"line-numbers\">location \/apis { \n    #\u6dfb\u52a0\u8bbf\u95ee\u76ee\u5f55\u4e3a\/apis\u7684\u4ee3\u7406\u914d\u7f6e\n            rewrite  ^\/apis\/(.*)$ \/$1 break;\n            proxy_pass   http:\/\/192.168.1.107:8011;\n       }\n<\/code><\/pre>\n<p>\u4fee\u6539\u5b8c\u6210\u540e\u7684\u5b8c\u6574\u6587\u4ef6\u5185\u5bb9\uff1a<\/p>\n<pre><code class=\"language-javascript line-numbers\">server {\n        listen       8090;\n        server_name  localhost;\n\n        #charset koi8-r;\n\n        #access_log  logs\/host.access.log  main;\n\n        location \/ {\n            #root   html;\n            #index  index.html index.htm;\n            proxy_pass http:\/\/localhost:8090;\n            proxy_redirect default;\n        }\n        location \/apis { \n            #\u6dfb\u52a0\u8bbf\u95ee\u76ee\u5f55\u4e3a\/apis\u7684\u4ee3\u7406\u914d\u7f6e\n            rewrite  ^\/apis\/(.*)$ \/$1 break;\n            proxy_pass   http:\/\/192.168.1.107:8011;\n       }\n\n        #error_page  404              \/404.html;\n\n        # redirect server error pages to the static page \/50x.html\n        #\n        error_page   500 502 503 504  \/50x.html;\n        location = \/50x.html {\n            root   html;\n        }\n\n        # proxy the PHP scripts to Apache listening on 127.0.0.1:80\n        #\n        #location ~ \\.php$ {\n        #    proxy_pass   http:\/\/127.0.0.1;\n        #}\n\n        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000\n        #\n        #location ~ \\.php$ {\n        #    root           html;\n        #    fastcgi_pass   127.0.0.1:9000;\n        #    fastcgi_index  index.php;\n        #    fastcgi_param  SCRIPT_FILENAME  \/scripts$fastcgi_script_name;\n        #    include        fastcgi_params;\n        #}\n\n        # deny access to .htaccess files, if Apache's document root\n        # concurs with nginx's one\n        #\n        #location ~ \/\\.ht {\n        #    deny  all;\n        #}\n    }\n<\/code><\/pre>\n<h3>6. \u542f\u52a8\u670d\u52a1<\/h3>\n<ol>\n<li>CD\u56de\u5230\u6839\u76ee\u5f55<\/p>\n<\/li>\n<li>\n<p><strong>.\/start nginx<\/strong>\u542f\u52a8\u670d\u52a1\uff08windows\u76f4\u63a5<strong>\u53cc\u51fb.exe<\/strong>\u6587\u4ef6\uff09<\/p>\n<\/li>\n<\/ol>\n<h3>7. \u5b89\u88c5anywhere<\/h3>\n<p>\u4f7f\u7528npm\u5168\u5c40\u5b89\u88c5anywhere\uff1a<\/p>\n<pre><code class=\"line-numbers\">npm i -g anywhere\n<\/code><\/pre>\n<p>\u4f7f\u7528\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"line-numbers\">anywhere -p8090\n<\/code><\/pre>\n<p>\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u542f\u52a8\u90fd\u4f1a\u81ea\u52a8\u6253\u5f00\u6d4f\u89c8\u5668\uff0c\u5e76\u6307\u5b9a\u9ed8\u8ba4\u5165\u53e3\u4e3a\u5f53\u524d\u547d\u4ee4\u76ee\u5f55\u3002<\/p>\n<p><em>note:<\/em><\/p>\n<p><em>\u9700\u8981\u5c06\u9879\u76ee\u4e2d\u7684\u6839\u8def\u5f84\u6539\u4e3a\u81ea\u5df1\u670d\u52a1\u5668\u7684\u5730\u5740\u548c\u7aef\u53e3\u3002\u4f8b\u5982\uff1aconst baseUrl = &#8216;http:\/\/192.168.1.100:8090\/apis\/\u670d\u52a1\u5668\u76f8\u5bf9\u8def\u5f84&#8217;;<\/em><\/p>\n<p>code enjoy!   \u0669(\u0e51\u275b\u1d17\u275b\u0e51)\u06f6<\/p>\n<p>\u4f5c\u8005\uff1aindeex<\/p>\n<p>\u94fe\u63a5\uff1a<a class=\"wp-editor-md-post-content-link\" href=\"http:\/\/indeex.cc\/\">http:\/\/indeex.cc<\/a><\/p>\n<p>\u8457\u4f5c\u6743\u5f52\u4f5c\u8005\u6240\u6709\u3002\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u8054\u7cfb\u4f5c\u8005\u83b7\u5f97\u6388\u6743\uff0c\u975e\u5546\u4e1a\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904\u3002<\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u3000\u3000\u3000\u3000 \u7531\u4e8eWEB\u5f00\u53d1\u7684\u5b89\u5168\u6027\u95ee\u9898\uff0c\u5f80\u5f80\u8bbf\u95ee\u670d\u52a1\u5668\u7684\u65f6\u5019\u9700\u8981\u9a8c\u8bc1\u8eab\u4efd\uff0c\u800c\u6709\u4e9b\u8d44\u6e90\u662f\u4e0d\u9700\u8981\u9a8c\u8bc1\u8eab\u4efd<a href=\"https:\/\/blog.indeex.club\/index.php\/2012\/09\/22\/%e5%8f%8d%e4%bb%a3%e7%90%86\/\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[4],"_links":{"self":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/107"}],"collection":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/comments?post=107"}],"version-history":[{"count":1,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/107\/revisions"}],"predecessor-version":[{"id":108,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/posts\/107\/revisions\/108"}],"wp:attachment":[{"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/media?parent=107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/categories?post=107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.indeex.club\/index.php\/wp-json\/wp\/v2\/tags?post=107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}