{"id":5127,"date":"2019-10-18T18:39:42","date_gmt":"2019-10-18T10:39:42","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=5127"},"modified":"2023-05-01T18:35:12","modified_gmt":"2023-05-01T10:35:12","slug":"semanage","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/semanage","title":{"rendered":"semanage\u547d\u4ee4 &#8211; \u67e5\u8be2\u4e0e\u4fee\u6539\u5b89\u5168\u4e0a\u4e0b\u6587"},"content":{"rendered":"\n<p>semanage\u547d\u4ee4\u6765\u81ea\u82f1\u6587\u8bcd\u7ec4\u201cSELinux manage\u201d\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u67e5\u8be2\u4e0e\u4fee\u6539\u5b89\u5168\u4e0a\u4e0b\u6587\u3002semanage\u7684\u529f\u80fd\u7c7b\u4f3c\u4e8echcon\u547d\u4ee4\uff0c\u5b83\u4eec\u90fd\u53ef\u4ee5\u7528\u4e8e\u8bbe\u7f6e\u6587\u4ef6\u7684SELinux\u5b89\u5168\u4e0a\u4e0b\u6587\u7b56\u7565\uff0c\u800csemanage\u547d\u4ee4\u529f\u80fd\u66f4\u5f3a\u5927\u4e00\u4e9b\uff0c\u8fd8\u80fd\u591f\u5bf9\u7cfb\u7edf\u7aef\u53e3\u3001\u8fdb\u7a0b\u7b49SELinux\u57df\u7b56\u7565\u8fdb\u884c\u67e5\u8be2\u548c\u4fee\u6539\uff0c\u56e0\u6b64\u66f4\u63a8\u8350\u4f7f\u7528\u3002<\/p>\n\n\n\n<p>*\u8bbe\u7f6e\u8fc7\u540e\u9700\u8981\u4f7f\u7528restorecon\u547d\u4ee4\u8ba9\u65b0\u8bbe\u7f6e\u7684\u5b89\u5168\u4e0a\u4e0b\u6587\u503c\u7acb\u5373\u751f\u6548\u3002<\/p>\n\n\n\n<p><strong>\u8bed\u6cd5\u683c\u5f0f\uff1a<\/strong>semanage [\u53c2\u6570] [\u5bf9\u8c61]<\/p>\n\n\n\n<p><strong>\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><tbody><tr><td>-a<\/td><td>\u589e\u52a0<\/td><\/tr><tr><td>-d<\/td><td>\u5220\u9664<\/td><\/tr><tr><td>-l<\/td><td>\u67e5\u8be2<\/td><\/tr><tr><td>-m<\/td><td>\u4fee\u6539<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p><strong>\u53c2\u8003\u793a\u4f8b<\/strong><\/p>\n\n\n\n<p>\u5bf9\u6307\u5b9a\u76ee\u5f55\u548c\u6587\u4ef6\u6dfb\u52a0\u65b0\u7684SELinux\u5b89\u5168\u4e0a\u4e0b\u6587\u503c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# <strong>semanage fcontext -a -t httpd_sys_content_t \/Dir\/wwwroot<\/strong>\n[root@linuxcool ~]# <strong>semanage fcontext -a -t httpd_sys_content_t <strong>\/Dir<\/strong>\/wwwroot\/*<\/strong><\/pre>\n\n\n\n<p>\u67e5\u8be2\u6307\u5b9a\u670d\u52a1\u6240\u5bf9\u5e94\u7684SELinux\u57df\u5141\u8bb8\u7aef\u53e3\u5217\u8868\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# <strong>semanage port -l | grep http<\/strong>\nhttp_cache_port_t            tcp      8080, 8118, 8123, 10001-10010\nhttp_cache_port_t            udp      3130\nhttp_port_t                  tcp      80, 81, 443, 488, 8008, 8009, 8443, 9000\npegasus_http_port_t          tcp      5988\npegasus_https_port_t         tcp      5989<\/pre>\n\n\n\n<p>\u5bf9\u6307\u5b9a\u670d\u52a1\u6240\u5bf9\u5e94\u7684SELinux\u57df\u5141\u8bb8\u7aef\u53e3\u5217\u8868\u6dfb\u52a0\u65b0\u7684\u503c\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[root@linuxcool ~]# <strong>semanage port -a -t http_port_t -p tcp 6111<\/strong><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>semanage\u547d\u4ee4\u6765\u81ea\u82f1\u6587\u8bcd\u7ec4\u201cSELinux manage\u201d\u7684\u7f29\u5199\uff0c\u5176\u529f\u80fd\u662f\u7528\u4e8e\u67e5\u8be2\u4e0e\u4fee\u6539\u5b89\u5168\u4e0a\u4e0b\u6587\u3002se [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5127","post","type-post","status-publish","format-standard","hentry","category-file"],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/5127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=5127"}],"version-history":[{"count":11,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/5127\/revisions"}],"predecessor-version":[{"id":14697,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/5127\/revisions\/14697"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=5127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=5127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=5127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}