{"id":516,"date":"2024-09-12T16:32:30","date_gmt":"2024-09-12T08:32:30","guid":{"rendered":"https:\/\/www.yanwenkai.com\/?p=516"},"modified":"2024-09-12T16:32:30","modified_gmt":"2024-09-12T08:32:30","slug":"linux%e7%b3%bb%e7%bb%9f%e4%bd%bf%e7%94%a8%e5%bf%83%e5%be%97","status":"publish","type":"post","link":"https:\/\/www.yanwenkai.com\/?p=516","title":{"rendered":"Linux\u7cfb\u7edf\u4f7f\u7528\u5fc3\u5f97"},"content":{"rendered":"<h1>1 \u524d\u8a00<\/h1>\n<p>&emsp;&emsp;\u65e5\u5e38\u4f7f\u7528linux\u65f6\u603b\u4f1a\u9047\u5230\u5404\u79cd\u5404\u6837\u7684\u95ee\u9898\uff0c\u67e5\u9605\u8d44\u6599\u603b\u7ed3\u540e\u60f3\u7740\u8fd9\u4e9b\u95ee\u9898\u4e0d\u4f1a\u53ea\u6709\u6211\u4e00\u4e2a\u4eba\u9047\u5230\u8fc7\uff0c\u8fd9\u91cc\u5c31\u7edf\u4e00\u6574\u7406\u4e00\u4e0b\u505a\u4e2a\u5206\u4eab\u3002<\/p>\n<h1>2 \u6269\u5c55SWAP\u5206\u533a<\/h1>\n<p>&emsp;&emsp;\u5728\u65e5\u5e38\u4f7f\u7528\u65f6\uff0c\u521b\u5efa\u7684\u865a\u62df\u673a\u603b\u4f1a\u9047\u5230\u5185\u5b58\u4e0d\u591f\u7528\u7684\u95ee\u9898\uff0c\u4f1a\u5f71\u54cd\u7f16\u8bd1\u901f\u5ea6\u3002\u8fd9\u65f6\u5c31\u9700\u8981\u914d\u7f6e\u865a\u62df\u5185\u5b58\u6269\u5c55swap\u5206\u533a\u4e86\u3002<\/p>\n<pre><code class=\"language-c\"># 1.\u521b\u5efa\u5206\u533a\u8def\u5f84\nsudo mkdir -p \/var\/cache\/swap\/\n# 2.\u8bbe\u7f6e\u5206\u533a\u7684\u5927\u5c0f\n# bs=64M\u662f\u5757\u5927\u5c0f\uff0ccount=64\u662f\u5757\u6570\u91cf\uff0c\u6240\u4ee5swap\u7a7a\u95f4\u5927\u5c0f\u662fbs*count=4096MB=4GB   \/\/1600\u662f100g\nsudo dd if=\/dev\/zero of=\/var\/cache\/swap\/swap0 bs=64M count=64\n# 3.\u8bbe\u7f6e\u8be5\u76ee\u5f55\u6743\u9650\nsudo chmod 0600 \/var\/cache\/swap\/swap0\n# 4.\u521b\u5efaSWAP\u6587\u4ef6\nsudo mkswap \/var\/cache\/swap\/swap0\n# 5.\u6fc0\u6d3bSWAP\u6587\u4ef6\nsudo swapon \/var\/cache\/swap\/swap0\n# 6.\u67e5\u770bSWAP\u4fe1\u606f\u662f\u5426\u6b63\u786e\nsudo swapon -s\n# 7.\u67e5\u770b\u5206\u533a\u60c5\u51b5\nfree -h<\/code><\/pre>\n<p>&emsp;&emsp;\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u8fd9\u4e2a\u914d\u7f6e\u4e00\u65e6\u5173\u673a\u540e\u5c31\u4f1a\u5931\u6548\uff0c\u9700\u8981\u5199\u5230\u914d\u7f6e\u6587\u4ef6\u4e2d<\/p>\n<pre><code class=\"language-c\">\u4f7f\u7528\u8be5\u65b9\u6cd5\u540e\u9700\u8981\u5c06\u8be5\u5206\u533a\u6dfb\u52a0\u81f3\/etc\/fstab\u4e2d\uff0c\u5426\u5219\u91cd\u542f\u540e\u7a7a\u95f4\u8fd8\u662f\u539f\u6765\u7684\u5927\u5c0f\n[root@elements ~]# vim \/etc\/fstab \n\/var\/cache\/swap\/swap0   none                    swap    defaults        0 0 \nmount -a    \u81ea\u52a8\u6302\u8f7d\uff0c\u68c0\u6d4bfstab\u662f\u5426\u4e66\u5199\u6b63\u786e<\/code><\/pre>\n<p>&emsp;&emsp;\u6ce8\uff1a\u914d\u7f6e\u5b8c\u6210\u540e\u4e00\u5b9a\u8981\u4f7f\u7528mount -a\u68c0\u67e5\u6302\u8f7d\u662f\u5426\u6b63\u786e\uff0c\u5199\u9519\u4e86\u673a\u5668\u91cd\u542f\u5c31\u8d77\u4e0d\u6765\u4e86\u3002\u5982\u679c\u5199\u9519\u4e86\uff0c\u9700\u8981\u8fdb\u6551\u63f4\u628a\u5199\u9519\u7684\u914d\u7f6e\u5220\u6389\u624d\u884c\u3002<\/p>\n<h1>3 \u914d\u7f6e\u79c1\u6709\u7684\u7f51\u7edc\u6e90<\/h1>\n<p>&emsp;&emsp;\u5de5\u4f5c\u91cc\u603b\u4f1a\u6709\u4f20\u6587\u4ef6\u7ed9\u5176\u4ed6\u4eba\u7684\u9700\u6c42\uff0c\u7b80\u5355\u914d\u7f6e\u4e00\u4e2a\u81ea\u5df1\u7684\u6587\u4ef6\u670d\u52a1\u5668\uff0c\u8fd9\u6837\u4fdd\u5b58\u548c\u4f20\u8f93\u6587\u4ef6\u5c31\u65b9\u4fbf\u591a\u4e86\u3002<\/p>\n<h2>3.1 nginx\u914d\u7f6e\u7f51\u7edc\u6e90<\/h2>\n<pre><code class=\"language-c\">[root@localhost tmp]# yum install nginx*  \/\/\u5b89\u88c5\u6240\u6709nginx\u7684\u8f6f\u4ef6\u5305\n[root@localhost tmp]# vim \/etc\/nginx\/conf.d\/default.conf \/\/\u6253\u5f00\u914d\u7f6e\u6587\u4ef6\uff0c\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\nserver {\n    charset      utf-8;\n    listen       80;\n    server_name  localhost;\n\n    location \/{\n        root   \/an8\/;\n        #index  index.html index.htm index.php;\n        autoindex on;\n        autoindex_exact_size off;\n        autoindex_localtime on;\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   \/var\/www\/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    location ~ \\.php$ {\n        root           \/var\/www\/html;\n        fastcgi_pass   127.0.0.1:9000;\n        fastcgi_index  index.php;\n        fastcgi_split_path_info ^(.+\\.php)(\/.+)$;\n        fastcgi_param  PATH_INFO $fastcgi_path_info;\n        fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;\n        fastcgi_param  SCRIPT_FILENAME  $document_root$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}<\/code><\/pre>\n<p>&emsp;&emsp;\u91cd\u542fnginx\u670d\u52a1<\/p>\n<pre><code class=\"language-c\">systemctl restart nginx.service\nsystemctl status nginx.service\nsystenctk stop  firewalld.service<\/code><\/pre>\n<p>&emsp;&emsp;\u521b\u5efanginx\u7f51\u7edc\u6e90\uff0c\u5b89\u88c5\u8f6f\u4ef6\u540e\uff0c\u5728\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u8981\u653e\u7f6e\u5305\u7684\u76ee\u5f55\uff0ccreaterepo\u5efa\u7acb\u7d22\u5f15\u3002<\/p>\n<pre><code class=\"language-c\">\/\/\u4f8b\u5982\u5728\u6839\u4e0b\u5efa\u7acb\u4e86an8\u7684\u76ee\u5f55\ncd \/an8\nmv .\/\u9700\u8981\u653e\u7f6e\u7684\u6587\u4ef6 \/an8\ncreaterepo .\/<\/code><\/pre>\n<p>&emsp;&emsp;\u7136\u540e\u5728\u6d4f\u89c8\u5668\u8f93\u5165\u81ea\u5df1\u7684\u673a\u5668ip+\u76ee\u5f55\u540d\u5c31\u53ef\u4ee5\u770b\u5230\u6587\u4ef6\u4e0b\u8f7d\u6e90\u4e86\u3002<\/p>\n<h2>3.2 \u4f7f\u7528httpd\u914d\u7f6e\u7f51\u7edc\u6e90<\/h2>\n<p>&emsp;&emsp;\u9664\u4e86nginx\u5916\uff0chttpd\u4e5f\u53ef\u4ee5\u914d\u7f6e\u7f51\u7edc\u6e90\u3002\u5982\u4e0b\u662f\u7b80\u5355\u7684\u914d\u7f6e\u65b9\u6cd5<\/p>\n<pre><code class=\"language-c\">\/\/\u5f00\u542fhttpd\u6a21\u5757\uff0c\u5b89\u88c5httpd\u7684\u8f6f\u4ef6\u5305\ndnf module enable httpd\nyum install httpd<\/code><\/pre>\n<pre><code class=\"language-c\">vim \/etc\/httpd\/conf\/httpd.conf\n\/\/\u52a0\u4e0a\u5982\u4e0b\u5185\u5bb9\n    Alias \/myrepo \/an8  \/\u5728\u6839\u4e0b\u521b\u5efa\u6587\u4ef6\u5939\uff0c\u524d\u9762\u662f\u8bbf\u95ee\u65f6\u7684\u540d\u79f0\n    <Directory \"\/an8\">\n        Options Indexes FollowSymLinks\n        AllowOverride None\n        Require all granted\n    <\/Directory><\/code><\/pre>\n<p>&emsp;&emsp;\u91cd\u542fhttpd\u670d\u52a1\uff0c\u5173\u95ed\u9632\u706b\u5899<\/p>\n<pre><code class=\"language-c\">systemctl restart httpd.service\nsystemctl status httpd.service\nsystenctk stop  firewalld.service<\/code><\/pre>\n<p>&emsp;&emsp;\u5728\u6839\u76ee\u5f55\u4e0b\u521b\u5efa\u8981\u653e\u7f6e\u5305\u7684\u76ee\u5f55\uff0ccreaterepo\u5efa\u7acb\u7d22\u5f15\u3002<\/p>\n<pre><code class=\"language-c\">\/\/\u4f8b\u5982\u5728\u6839\u4e0b\u5efa\u7acb\u4e86an8\u7684\u76ee\u5f55\ncd \/an8\nmv .\/\u9700\u8981\u653e\u7f6e\u7684\u6587\u4ef6 \/an8\ncreaterepo .\/<\/code><\/pre>\n<p>&emsp;&emsp;\u6b64\u65f6\u5728\u6d4f\u89c8\u5668\u8f93\u5165ip+\u76ee\u5f55\u540d\u5373\u53ef\u8bbf\u95ee\u81ea\u5df1\u7684\u6587\u4ef6\u540d\u79f0\u4e86\u3002<\/p>\n<p><center><br \/>\n<div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/www.yanwenkai.com:7777\/images\/2024\/09\/12\/2024-09-03-16.png'><img class=\"lazyload lazyload-style-1\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  loading=\"lazy\" decoding=\"async\" data-original=\"https:\/\/www.yanwenkai.com:7777\/images\/2024\/09\/12\/2024-09-03-16.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" width=\"600\" height=\"400\"><\/div><br \/>\n<\/center><\/p>\n<h1>4 \u603b\u7ed3<\/h1>\n<p>&emsp;&emsp;\u65e5\u5e38\u5206\u4eab\u4f7f\u7528linux\u65f6\u9047\u5230\u7684\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u5f0f\uff0c\u6301\u7eed\u66f4\u65b0\u8bf7\u968f\u65f6\u5173\u6ce8\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1 \u524d\u8a00 &emsp;&emsp;\u65e5\u5e38\u4f7f\u7528linux\u65f6\u603b\u4f1a\u9047\u5230\u5404\u79cd\u5404\u6837\u7684\u95ee\u9898\uff0c\u67e5\u9605\u8d44\u6599\u603b\u7ed3\u540e\u60f3\u7740\u8fd9\u4e9b\u95ee\u9898\u4e0d\u4f1a\u53ea [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":520,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[34,40,39],"class_list":["post-516","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-3","tag-c-c","tag-centos","tag-linux"],"_links":{"self":[{"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=\/wp\/v2\/posts\/516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=516"}],"version-history":[{"count":2,"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=\/wp\/v2\/posts\/516\/revisions"}],"predecessor-version":[{"id":519,"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=\/wp\/v2\/posts\/516\/revisions\/519"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=\/wp\/v2\/media\/520"}],"wp:attachment":[{"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yanwenkai.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}