{"id":26,"date":"2024-08-13T11:42:49","date_gmt":"2024-08-13T03:42:49","guid":{"rendered":"http:\/\/8.134.236.44\/wordpress\/?p=26"},"modified":"2024-08-24T21:51:27","modified_gmt":"2024-08-24T13:51:27","slug":"linux%e5%ae%89%e8%a3%85nginx","status":"publish","type":"post","link":"https:\/\/rrt01.cn\/?p=26","title":{"rendered":"Linux\u5b89\u88c5nginx"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/rrt01.cn\/wp-content\/uploads\/2024\/08\/OIP-C-1.jpg\" alt=\"\" \/><\/p>\n\n\n<p><strong>1. \u5b89\u88c5\u4f9d\u8d56\u9879<\/strong><\/p>\n\n\n\n<p>\u786e\u4fddNgnix\u7f16\u8bd1\u548c\u8fd0\u884c\u6b63\u5e38\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">yum install -y wget gcc-c++ pcre-devel zlib-devel openssl-devel<\/pre>\n\n\n\n<p><strong>2. \u4e0b\u8f7dNginx\u5e76\u89e3\u538b<\/strong><\/p>\n\n\n\n<p>\u5b98\u7f51\uff1a<a href=\"https:\/\/nginx.org\/en\/download.html?spm=a2c6h.13046898.publish-article.13.71ab6ffaCvvtmR\"><a href=\"https:\/\/nginx.org\/en\/download.html\">https:\/\/nginx.org\/en\/download.html<\/a><\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">wget https:\/\/nginx.org\/download\/nginx-1.24.0.tar.gz # \u4e0b\u8f7d<br>tar -zxvf nginx-1.24.0.tar.gz # \u89e3\u538b<\/pre>\n\n\n\n<p><strong>3. \u7f16\u8bd1\u548c\u5b89\u88c5<\/strong><\/p>\n\n\n\n<p>\u8fdb\u5165\u89e3\u538b\u540e\u7684Nginx\u8fdb\u884c\u7f16\u8bd1\u548c\u5b89\u88c5<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u5207\u6362\u5230 Nginx \u89e3\u538b\u76ee\u5f55<br>cd nginx-1.24.0<br># \u7f16\u8bd1\u524d\u7684\u914d\u7f6e\u548c\u4f9d\u8d56\u68c0\u67e5<br>.\/configure<br># \u7f16\u8bd1\u5b89\u88c5<br>make &amp;&amp; make install<\/pre>\n\n\n\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u9ed8\u8ba4\u81ea\u52a8\u521b\u5efa<code>\/usr\/local\/nginx<\/code>\u76ee\u5f55\uff0c\u5e76\u521b\u5efa\u5fc5\u8981\u7684\u6587\u4ef6\u548c\u76ee\u5f55<\/p>\n\n\n\n<p><strong>4. \u9632\u706b\u5899\u8bbe\u7f6e<\/strong><\/p>\n\n\n\n<p>\u82e5\u7cfb\u7edf\u542f\u7528\u4e86\u9632\u706b\u5899\uff0c\u9700\u5173\u95ed<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u67e5\u770b\u9632\u706b\u5899\u72b6\u6001<br>systemctl status firewalld<br>\u200b<br># \u5173\u95ed\u9632\u706b\u5899<br>systemctl stop firewalld<br>\u200b<br># \u5f00\u673a\u7981\u7528\u9632\u706b\u5899<br>systemctl disable firewalld<\/pre>\n\n\n\n<p><strong>5. \u542f\u52a8Nginx<\/strong><\/p>\n\n\n\n<p>\u8fdb\u5165Nginx\u7684\u5b89\u88c5\u76ee\u5f55\uff0c\u7136\u540e\u542f\u52a8Nginx\u670d\u52a1\u5668<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd \/usr\/local\/nginx\/sbin<br>.\/nginx<\/pre>\n\n\n\n<p>\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u670d\u52a1\u5668\u7684IP\u5730\u5740\u6216\u8005\u57df\u540d\u9a8c\u8bc1Nginx\u80fd\u5426\u6b63\u5e38\u5de5\u4f5c<\/p>\n\n\n\n<p><strong>6. \u914d\u7f6eNginx\u4e3a\u7cfb\u7edf\u670d\u52a1<\/strong><\/p>\n\n\n\n<p>\u5728 \/etc\/systemd\/system\/ \u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u670d\u52a1\u6587\u4ef6\uff0c\u4f8b\u5982 nginx.service\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">vi \/etc\/systemd\/system\/nginx.service<\/pre>\n\n\n\n<p>\u5728\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u6dfb\u52a0\u5982\u4e0b\u5185\u5bb9\u540e\u4fdd\u5b58\uff08\u5982\u679c\u8def\u5f84\u548c\u7248\u672c\u53f7\u4e0d\u4e00\u6837\uff0c\u6089\u6570\u66f4\u6539\uff09<br>[Unit]<br>Description=nginx<br>After=network.target<br>[Service]<br>Type=forking<br>ExecStart=\/usr\/local\/nginx\/sbin\/nginx -c \/usr\/local\/nginx\/conf\/nginx.conf<br>ExecReload=\/usr\/local\/nginx\/sbin\/nginx -s reload<br>ExecStop=\/usr\/local\/nginx\/sbin\/nginx -s stop<br>PrivateTmp=true<br>[Install]<br>WantedBy=multi-user.target<\/pre>\n\n\n\n<p><strong>7. \u542f\u52a8Nginx\u670d\u52a1<\/strong><\/p>\n\n\n\n<p>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8Nginx\u670d\u52a1<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl start nginx<\/pre>\n\n\n\n<p>\u6b64\u65f6\uff0cNginx\u5c06\u4f5c\u4e3a\u7cfb\u7edf\u670d\u52a1\u5728\u540e\u53f0\u8fd0\u884c<\/p>\n\n\n\n<p><strong>8. \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f\u52a8<\/strong><\/p>\n\n\n\n<p>\u7cfb\u7edf\u542f\u52a8\u65f6Nginx\u81ea\u52a8\u542f\u52a8<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl enable nginx<\/pre>\n\n\n\n<p><strong>9. \u68c0\u67e5Nginx\u72b6\u6001<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl status nginx<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"\" alt=\"image-20240809143320788\"\/><\/figure>\n\n\n\n<p><strong>10. \u505c\u6b62Nginx\u670d\u52a1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl stop nginx<\/pre>\n\n\n\n<p><strong>11. \u91cd\u542fNginx\u670d\u52a1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">systemctl restart nginx<\/pre>\n\n\n\n<p><strong>12. \u5378\u8f7dNginx\u670d\u52a1<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u505c\u6b62Nginx\u670d\u52a1 <code>systemctl restart nginx<\/code><\/li>\n\n\n\n<li>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u975e\u7cfb\u7edf\u670d\u52a1\u65b9\u5f0f\u542f\u52a8Nginx\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u505c\u6b62Nginx\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">\/usr\/local\/nginx\/sbin\/nginx -s stop<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u627eNginx\u7684\u5b89\u88c5\u4f4d\u7f6e\uff1b\u547d\u4ee4\u5c06\u8fd4\u56deNginx\u53ef\u6267\u884c\u6587\u4ef6\u7684\u8def\u5f84\uff0c\u4f8b\u5982 \/usr\/local\/nginx\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">whereis nginx<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5220\u9664Nginx\u5b89\u88c5\u76ee\u5f55<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">rm -rf \/usr\/local\/nginx<\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u627e\u53ef\u80fd\u4e0eNginx\u76f8\u5173\u7684\u6587\u4ef6<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-preformatted\">find \/ -name nginx<\/pre>\n\n\n\n<p>\u8fd9\u5c06\u641c\u7d22\u6587\u4ef6\u7cfb\u7edf\u4e2d\u6240\u6709\u5305\u542b \u201cnginx\u201d \u7684\u6587\u4ef6\u540d\uff0c\u5e76\u4e14\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u5220\u9664\u8fd9\u4e9b\u6587\u4ef6\u3002\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u540e\uff0cNginx\u5c06\u88ab\u5b8c\u5168\u5378\u8f7d\u3002<\/p>\n\n\n\n<p><strong>13. \u67e5\u770bNginx\u662f\u5426\u6b63\u5e38\u8fd0\u884c<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">ps -ef | grep nginx<\/pre>\n\n\n\n<p>\u5982\u679c\u8be5\u547d\u4ee4\u8f93\u51faNginx\u8fdb\u7a0b\u4fe1\u606f\uff0c\u8bf4\u660eNginx\u6b63\u5728\u8fd0\u884c<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5b89\u88c5\u4f9d\u8d56\u9879 \u786e\u4fddNgnix\u7f16\u8bd1\u548c\u8fd0\u884c\u6b63\u5e38\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4 yum install -y wget gcc-&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-26","post","type-post","status-publish","format-standard","hentry","category-3"],"views":1439,"_links":{"self":[{"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/posts\/26"}],"collection":[{"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rrt01.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26"}],"version-history":[{"count":8,"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":97,"href":"https:\/\/rrt01.cn\/index.php?rest_route=\/wp\/v2\/posts\/26\/revisions\/97"}],"wp:attachment":[{"href":"https:\/\/rrt01.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rrt01.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rrt01.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}