{"id":22,"date":"2021-06-22T22:31:16","date_gmt":"2021-06-22T14:31:16","guid":{"rendered":"http:\/\/www.tysql.com\/?p=22"},"modified":"2021-06-22T22:31:28","modified_gmt":"2021-06-22T14:31:28","slug":"linux%e5%ae%89%e8%a3%85nginx","status":"publish","type":"post","link":"https:\/\/www.tysql.com\/index.php\/2021\/06\/22\/linux%e5%ae%89%e8%a3%85nginx\/","title":{"rendered":"LINUX\u5b89\u88c5nginx"},"content":{"rendered":"\n<p><strong>1.\u5b89\u88c5\u4f9d\u8d56\u5305<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">\/\/\u4e00\u952e\u5b89\u88c5\u4e0a\u9762\u56db\u4e2a\u4f9d\u8d56\nyum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel<\/pre><\/div>\n\n\n\n<p><strong>2.\u4e0b\u8f7d\u5e76\u89e3\u538b\u5b89\u88c5\u5305<\/strong><\/p>\n\n\n\n<p>\u8fd9\u91cc\u662f1.20.0\u7248\u672c \u53ef\u4ee5\u53bbnginx\u5b98\u7f51\u67e5\u770b\u6700\u65b0\u7248\u672c\u53f7&nbsp;<a href=\"http:\/\/nginx.org\/download\/\">http:\/\/nginx.org\/download\/<\/a><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">\/\/\u521b\u5efa\u4e00\u4e2a\u6587\u4ef6\u5939\ncd \/usr\/local\nmkdir nginx\ncd nginx\n\/\/\u4e0b\u8f7dtar\u5305\nwget http:\/\/nginx.org\/download\/nginx-1.20.0.tar.gz\ntar -xvf nginx-1.20.0.tar.gz<\/pre><\/div>\n\n\n\n<p>\u8fd9\u91cc\u5982\u679cwget\u62a5\u9519\u53ef\u80fd\u662f\u6ca1\u6709\u5b89\u88c5,yum\u65b9\u5f0f\u5b89\u88c5.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">yum -y install wget<\/pre><\/div>\n\n\n\n<p><strong>3.\u5b89\u88c5nginx<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">\/\/\u8fdb\u5165nginx\u76ee\u5f55\ncd \/usr\/local\/nginx\n\/\/\u8fdb\u5165\u76ee\u5f55\ncd nginx-1.20.0\n\/\/\u6267\u884c\u547d\u4ee4\n.\/configure\n\/\/\u6267\u884cmake\u547d\u4ee4\nmake\n\/\/\u6267\u884cmake install\u547d\u4ee4\nmake install<\/pre><\/div>\n\n\n\n<p><strong>4.\u53ef\u4ee5\u6839\u636e\u9700\u6c42\u914d\u7f6enginx.conf<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\"># \u6253\u5f00\u914d\u7f6e\u6587\u4ef6\nvi \/usr\/local\/nginx\/conf\/nginx.conf<\/pre><\/div>\n\n\n\n<p><strong>5.\u542f\u52a8nginx<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">\/usr\/local\/nginx\/sbin\/nginx -s reload<\/pre><\/div>\n\n\n\n<p>\u5982\u679c\u51fa\u73b0\u62a5\u9519\uff1anginx: [error] open() \uff02\/usr\/local\/nginx\/logs\/nginx.pid\uff02 failed<\/p>\n\n\n\n<p>\u5219\u8fd0\u884c\u4e0b\u9762\u4ee3\u7801\u7ee7\u7eed\u542f\u52a8\u5373\u53ef.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">\/usr\/local\/nginx\/sbin\/nginx -c \/usr\/local\/nginx\/conf\/nginx.conf<\/pre><\/div>\n\n\n\n<p><strong>6.\u82e5\u60f3\u4f7f\u7528\u5916\u90e8\u4e3b\u673a\u8fde\u63a5\u4e0a\uff0c\u9700\u8981\u5173\u95ed\u9632\u706b\u5899\uff1a<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">\/\/centOS7\u5173\u95ed\u9632\u706b\u5899\nsystemctl stop firewalld.service\n\/\/\u7981\u6b62firewall\u5f00\u673a\u542f\u52a8\nsystemctl disable firewalld.service <\/pre><\/div>\n\n\n\n<p><strong><strong>7.\u8bbf\u95ee\u670d\u52a1\u5668ip\u67e5\u770b<\/strong><\/strong>,\u51fa\u73b0welcome to nginx \u5373\u5b89\u88c5\u6210\u529f.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img loading=\"lazy\" decoding=\"async\" width=\"568\" height=\"217\" src=\"http:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image.png\" alt=\"\" class=\"wp-image-23\" srcset=\"https:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image.png 568w, https:\/\/www.tysql.com\/wp-content\/uploads\/2021\/06\/image-300x115.png 300w\" sizes=\"auto, (max-width: 568px) 100vw, 568px\" \/><\/figure>\n\n\n\n<p><strong>8.\u5982\u679c\u9700\u8981\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8nginx<\/strong><\/p>\n\n\n\n<p><strong>\u8fdb\u5165\u5230\/lib\/systemd\/system\/\u76ee\u5f55<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">cd \/lib\/systemd\/system\/<\/pre><\/div>\n\n\n\n<p><strong>\u521b\u5efanginx.service\u6587\u4ef6\uff0c\u5e76\u7f16\u8f91<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">vi nginx.service<\/pre><\/div>\n\n\n\n<p>\u5185\u5982\u5982\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">[Unit]\nDescription=nginx service\nAfter=network.target \n   \n[Service] \nType=forking \nExecStart=\/usr\/local\/nginx\/sbin\/nginx\nExecReload=\/usr\/local\/nginx\/sbin\/nginx -s reload\nExecStop=\/usr\/local\/nginx\/sbin\/nginx -s quit\nPrivateTmp=true \n   \n[Install] \nWantedBy=multi-user.target<\/pre><\/div>\n\n\n\n<p><strong>\u52a0\u5165\u5f00\u673a\u81ea\u542f\u52a8<\/strong><\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\">systemctl enable nginx<\/pre><\/div>\n\n\n\n<p>\u4e00\u4e9b\u5feb\u6377\u64cd\u4f5c<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:false,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;apl&quot;,&quot;mime&quot;:&quot;text\/apl&quot;,&quot;theme&quot;:&quot;darcula&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;APL&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;apl&quot;}\"># systemctl start nginx.service\u3000         \u542f\u52a8nginx\u670d\u52a1\n# systemctl stop nginx.service\u3000          \u505c\u6b62\u670d\u52a1\n# systemctl restart nginx.service\u3000       \u91cd\u65b0\u542f\u52a8\u670d\u52a1\n# systemctl list-units --type=service     \u67e5\u770b\u6240\u6709\u5df2\u542f\u52a8\u7684\u670d\u52a1\n# systemctl status nginx.service          \u67e5\u770b\u670d\u52a1\u5f53\u524d\u72b6\u6001\n# systemctl enable nginx.service          \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8\n# systemctl disable nginx.service         \u505c\u6b62\u5f00\u673a\u81ea\u542f\u52a8<\/pre><\/div>\n\n\n\n<p>nginx \u5b89\u88c5\u53c2\u8003\u81ea<a href=\"https:\/\/blog.csdn.net\/t8116189520\/article\/details\/81909574\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/blog.csdn.net\/t8116189520\/article\/details\/81909574<\/a><\/p>\n\n\n\n<p>nginx\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8\u53c2\u8003\u81ea<a href=\"https:\/\/www.cnblogs.com\/jepson6669\/p\/9131217.html\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.cnblogs.com\/jepson6669\/p\/9131217.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.\u5b89\u88c5\u4f9d\u8d56\u5305 2.\u4e0b\u8f7d\u5e76\u89e3\u538b\u5b89\u88c5\u5305 \u8fd9\u91cc\u662f1.20.0\u7248\u672c \u53ef\u4ee5\u53bbnginx\u5b98\u7f51\u67e5\u770b\u6700\u65b0\u7248\u672c\u53f7&nbsp;h &hellip; <a href=\"https:\/\/www.tysql.com\/index.php\/2021\/06\/22\/linux%e5%ae%89%e8%a3%85nginx\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">LINUX\u5b89\u88c5nginx<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/comments?post=22"}],"version-history":[{"count":2,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":25,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/posts\/22\/revisions\/25"}],"wp:attachment":[{"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/media?parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/categories?post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tysql.com\/index.php\/wp-json\/wp\/v2\/tags?post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}