{"id":1111,"date":"2016-03-14T18:11:04","date_gmt":"2016-03-14T10:11:04","guid":{"rendered":"http:\/\/jingxianhome.aliapp.com\/?p=1111"},"modified":"2016-03-14T18:11:04","modified_gmt":"2016-03-14T10:11:04","slug":"linux-nginx%e5%ae%89%e8%a3%85-%e7%ae%80%e5%8d%95%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/www.yeetrack.com\/?p=1111","title":{"rendered":"linux nginx\u5b89\u88c5 &#038; \u7b80\u5355\u914d\u7f6e"},"content":{"rendered":"<h1>Linux\u5b89\u88c5nginx<\/h1>\n<h2>1. \u5b89\u88c5pcre<\/h2>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/sourceforge.net\/projects\/pcre\/files\/pcre\/8.38\/pcre-8.38.zip\/download\">https:\/\/sourceforge.net\/projects\/pcre\/files\/pcre\/8.38\/pcre-8.38.zip\/download<\/a><\/p>\n<p>\u89e3\u538b\uff0cconfig\uff0c\u7f16\u8bd1\uff0c\u5b89\u88c5<!--more--><\/p>\n<pre><code>    .\/configure --prefix=\/home\/yourpath\/pcre\n    make &amp;&amp; make install\n<\/code><\/pre>\n<h2>2. \u5b89\u88c5openssl<\/h2>\n<p>\u4e0b\u8f7d\u5730\u5740: <a href=\"https:\/\/www.openssl.org\/source\/openssl-1.0.2g.tar.gz\">https:\/\/www.openssl.org\/source\/openssl-1.0.2g.tar.gz<\/a><\/p>\n<p>\u89e3\u538b\uff0cconfig\uff0c\u7f16\u8bd1\uff0c\u5b89\u88c5<\/p>\n<pre><code>    .\/config --prefix=\/home\/yourpath\/openssl\n    make &amp;&amp; make install\n<\/code><\/pre>\n<h2>3. \u5b89\u88c5zlib<\/h2>\n<p>\u4e0b\u8f7d\u5730\u5740: <a href=\"http:\/\/zlib.net\/zlib-1.2.8.tar.gz\">http:\/\/zlib.net\/zlib-1.2.8.tar.gz<\/a><\/p>\n<p>\u89e3\u538b\uff0cconfig\uff0c\u7f16\u8bd1\uff0c\u5b89\u88c5<\/p>\n<pre><code>    .\/configure --prefix=\/home\/yourpath\/zlib\n    make &amp;&amp; make install\n<\/code><\/pre>\n<h2>4. \u5b89\u88c5nginx<\/h2>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a <a href=\"http:\/\/nginx.org\/download\/nginx-1.9.12.tar.gz\">http:\/\/nginx.org\/download\/nginx-1.9.12.tar.gz<\/a><\/p>\n<p>\u89e3\u538b\uff0cconfig\uff0c\u7f16\u8bd1\uff0c\u5b89\u88c5<\/p>\n<pre><code>    .\/configure --prefix=\/home\/yourpath\/nginx --with-pcre=\/home\/yourpath\/pcre-8.38 --with-openssl=\/home\/yourpath\/openssl-1.0.2g --with-zlib=\/home\/yourpath\/zlib-1.2.8\n    make &amp;&amp; make install\n<\/code><\/pre>\n<p>\u987a\u5229\u7684\u8bdd\uff0cnginx\u5b89\u88c5\u5b8c\u6bd5\uff0c\u5b89\u88c5\u8def\u5f84\u4e3a<code>\/home\/yourpath\/nginx<\/code>\u3002<\/p>\n<h2>5. \u6d4b\u8bd5<\/h2>\n<pre><code>    cd \/home\/yourpath\/nginx\/sbin\n    .\/nginx  \/\/\u542f\u52a8nginx\n<\/code><\/pre>\n<p>\u7528\u6d4f\u89c8\u5668\u8bbf\u95ee\u5373\u53ef\uff0c\u9ed8\u8ba480\u7aef\u53e3\u3002\u5982\u679c\u51fa\u73b0\u4e0b\u9762\u7684\u63d0\u793a\uff0c\u5219\u8868\u793a\u5b89\u88c5\u6210\u529f.<\/p>\n<pre><code>    Welcome to nginx!\n\n    If you see this page, the nginx web server is successfully installed and working. Further configuration is required.\n\n    For online documentation and support please refer to nginx.org.\n    Commercial support is available at nginx.com.\n\n    Thank you for using nginx.\n<\/code><\/pre>\n<h2>6. \u914d\u7f6e<\/h2>\n<p>\u4e3b\u8981\u7684\u914d\u7f6e\u5728<code>\/home\/yourpath\/nginx\/conf\/nginx.conf<\/code>\u6587\u4ef6\u4e2d<\/p>\n<pre><code>    worker_processes  1; \/\/\u914d\u7f6e\u591a\u5c11\u4e2awork\u8fdb\u7a0b\n    worker_connections  1024; \/\/\u6bcf\u4e2a\u5de5\u4f5c\u8fdb\u7a0b\u6700\u5927\u7684\u8fde\u63a5\u6570\n    listen       80; \/\/\u9ed8\u8ba4\u76d1\u542c80\u7aef\u53e3\n<\/code><\/pre>\n<p>\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2anginx\u4e0b\u53ef\u80fd\u914d\u7f6e\u591a\u4e2a\u57df\u540d\uff0c\u4f1a\u589e\u52a0\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u5728nginx.conf\u9ed8\u8ba4\u6dfb\u52a0 <code>include vhosts\/*.conf;<\/code>\uff0c\u7136\u540e\u5c06\u81ea\u5df1\u589e\u52a0\u7684\u914d\u7f6e\u6587\u4ef6\u90fd\u653e\u5728vhosts\u76ee\u5f55\u4e0b.<\/p>\n<h3>\u9759\u6001html\u6587\u4ef6\u4ee3\u7406<\/h3>\n<p>vhosts\/static.yeetrack.conf \u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code>    server {\n        listen 80;\n        server_name nginx.yeetrack.com;\n        access_log logs\/yeetrack.access.log;\n        error_log logs\/yeetrack.error.log;\n\n        location \/ {\n            root \/home\/victor\/work\/nginx\/myhtml;\n        }\n    }\n<\/code><\/pre>\n<p>\u5c06\u9759\u6001\u7684html\u3001css\u3001js\u6587\u4ef6\u653e\u5728\/home\/victor\/work\/nginx\/myhtml\u8def\u5f84\u4e0b\u5373\u53ef\u3002<br \/>\nreload nginx\uff1a<code>nginx\/sbin\/nginx -s reload<\/code>\u3002<\/p>\n<h3>tomcat\u670d\u52a1\u4ee3\u7406<\/h3>\n<p>nginx\u4ee3\u7406tomcat\u7b49\u670d\u52a1\uff0cvhosts\/tomcat.conf\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code>    upstream tomcat {\n        server 172.17.80.51:8080;\n    }\n\n    server {\n        listen 80;\n        server_name nginx.yeetrack.com;\n        access_log logs\/yeetrack.access.log;\n        error_log logs\/yeetrack.error.log;\n\n        location \/ {\n            proxy_pass http:\/\/tomcat;\n        }\n    }\n<\/code><\/pre>\n<p>reload nginx: <code>nginx\/sbin\/nginx -s reload<\/code><\/p>\n<h3>php\u670d\u52a1\u4ee3\u7406<\/h3>\n<p>nginx\u4ee3\u7406php\u670d\u52a1\uff0cvhosts\/php.conf\u5185\u5bb9\u5982\u4e0b\uff1a<br \/>\n\u9047\u5230*.php\u7ed3\u5c3e\u7684\u8bf7\u6c42\uff0cnginx\u4f1a\u5c06\u8bf7\u6c42\u8f6c\u53d1\u5230127.0.0.1\u76849000\u7aef\u53e3\uff0c\u7136\u540ephp\u4f1a\u5728\u672c\u673a\u7684\/home\/victor\/work\/static\u76ee\u5f55\u4e2d\u5bfb\u627e\u54cd\u5e94\u7684php\u6587\u4ef6\u8fdb\u884c\u89e3\u6790\uff1b\u5176\u4ed6\u7684\u8bf7\u6c42nginx\u4f1a\u5f53\u505a\u9759\u6001\u8d44\u6e90\uff0c\u5728nginx\u673a\u5668\u7684\/home\/victor\/work\/static\u76ee\u5f55\u4e2d\u67e5\u627e\u76f8\u5e94\u6587\u4ef6\u3002<\/p>\n<pre><code>    upstream php {\n        server 127.0.0.1:9000;\n    }\n\n    server {\n        listen 80;\n        server_name php.yeetrack.com;\n        access_log logs\/yeetrack.access.log main;\n        error_log logs\/yeetrack.error.log;\n        root \/home\/victor\/work\/static;\n\n\n        location ~ .php$ {\n            fastcgi_pass   php;\n            fastcgi_next_upstream error timeout invalid_header http_500;\n            fastcgi_index  index.php;\n            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;\n            include        fastcgi.conf;\n        }\n    }\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u5b89\u88c5nginx 1. \u5b89\u88c5pcre \u4e0b\u8f7d\u5730\u5740\uff1ahttps:\/\/sourceforge.net\/projects\/pcre\/files\/pcre\/8.38\/pcre-8.38.zip\/down&#46;&#46;&#46;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"pgc_sgb_lightbox_settings":"","footnotes":""},"categories":[34],"tags":[11,58],"class_list":["post-1111","post","type-post","status-publish","format-standard","hentry","category-software","tag-linux","tag-nginx"],"views":3390,"_links":{"self":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1111","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1111"}],"version-history":[{"count":1,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1111\/revisions"}],"predecessor-version":[{"id":1112,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=\/wp\/v2\/posts\/1111\/revisions\/1112"}],"wp:attachment":[{"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1111"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yeetrack.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}