{"id":232,"date":"2017-03-21T20:14:07","date_gmt":"2017-03-21T12:14:07","guid":{"rendered":"http:\/\/pony.hk\/?p=232"},"modified":"2017-12-04T07:37:00","modified_gmt":"2017-12-03T23:37:00","slug":"centos7-selinux-php%e7%9a%84-404-file-not-found","status":"publish","type":"post","link":"https:\/\/lnmp.ivan.xin\/?p=232","title":{"rendered":"CentOS7 SELinux PHP\u7684 404 File not found"},"content":{"rendered":"<p>\u66b4\u529b\u89e3\u51b3\uff1a\u628aSELinux\u4eceEnforcing\u5207\u6362\u5230Permissive\u3002\uff08\u4e34\u65f6\u4fee\u6539setenforce Permissive\u548csetenforce Enforcing\uff0c\u6c38\u4e45\u4fee\u6539vi \/etc\/selinux\/config\uff09<br \/>\n\u5206\u6790\uff1a<br \/>\n1\u3001\u6211\u7684\u914d\u7f6e\u6587\u4ef6\u548c\u7f51\u7ad9\u4ee3\u7801\u90fd\u662f\u4ece\u5176\u4ed6\u673a\u5668\u4e0a\u6253\u5305\u8fc7\u6765\u7684\uff0c\u73af\u5883\u5b89\u88c5\u5b8c\u4e4b\u540e\u53d1\u73b0\u6709\u8fd9\u4e2a\u95ee\u9898\u3002<br \/>\n2\u3001NGINX\u8bbf\u95eehtml\u6587\u4ef6\u4e00\u5207\u6b63\u5e38\uff0c\u8bbf\u95eephp\u6587\u4ef6\u603b\u662f\u62a5\u9519\uff0c404\uff0c\u6587\u4ef6\u65e0\u6cd5\u627e\u5230\uff0c\u4fee\u6539\u4e86\u6587\u4ef6\u6743\u9650\u4e3a777\uff0c\u4f9d\u7136\u62a5\u9519\uff0c\u8bf4\u660e\u4e0d\u662f\u7b80\u5355\u7684\u6587\u4ef6\u6743\u9650\u95ee\u9898\u3002<br \/>\n3\u3001\u67e5\u770bNGINX\u65e5\u5fd7\uff0c\u6709\u62a5\u9519\u201cFastCGI sent in stderr: \"Primary script unknown\" while reading response header from upstream\u201d\uff0c\u4ee5\u4e3a\u662fNGINX\u4e0ePHP\u901a\u4fe1\u7684\u9519\u8bef\uff0c\u6298\u817e\u4e86\u5f88\u4e45\uff0c\u91cd\u88c5\u4e86\u5f88\u591a\u6b21\uff0c\u4e5f\u6ca1\u627e\u5230\u95ee\u9898\u6240\u5728\u3002<br \/>\n4\u3001\u6362\u5404\u79cd\u65b9\u6cd5\u91cd\u88c5\uff0c\u6240\u6709\u8f6f\u4ef6\u5206\u522b\u6362yum\u5b89\u88c5\u548c\u7f16\u8bd1\u5b89\u88c5\uff0c\u5176\u4e2d\u6709\u7684\u5b89\u88c5\u662f\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u7684\uff0c\u8fd9\u65f6\u5019\u89c9\u5f97\u662f\u4e2a\u5f88\u795e\u5947\u7684\u73b0\u8c61\uff0c\u4e3a\u4ec0\u4e48\u6709\u65f6\u5019\u884c\uff1f\u6709\u65f6\u5019\u53c8\u4e0d\u884c\uff1f<br \/>\n5\u3001\u6240\u4ee5\u53c8\u6362\u4e00\u79cd\u65b9\u6cd5\uff1a\u91cd\u65b0\u5efa\u4e00\u4e2a\u7f51\u7ad9\u76ee\u5f55\uff0c\u5efaphpinfo.php\u6587\u4ef6\uff0c\u7ed3\u679c\u662f\u53ef\u4ee5\u8bbf\u95ee\uff01\u628a\u4e4b\u524d\u6587\u4ef6\u5939\u4e0d\u80fd\u8bbf\u95ee\u7684phpinfo.php\u6587\u4ef6mv\u8fc7\u6765\uff0c\u53c8\u4e0d\u80fd\u8bbf\u95ee\u4e86\uff01\u4fee\u6539\u6743\u9650\u4e3a777\u4e5f\u4e0d\u884c\u3002cp\u8fc7\u6765\uff0c\u5c31\u53ef\u4ee5\u8bbf\u95ee\uff01<br \/>\n6\u3001\u81f3\u6b64\uff0c\u5f88\u660e\u4e86\u4e86\uff0c\u4e0d\u662f\u8f6f\u4ef6\u7684\u95ee\u9898\uff0c\u4e0d\u662f\u6587\u4ef6\u6743\u9650\u7684\u95ee\u9898\uff0c\u662f\u7cfb\u7edf\u7684\u95ee\u9898\uff01SELinux\u5728\u4f5c\u602a\uff01<\/p>\n<p>\u5982\u679c\u4e0d\u60f3\u6539\u53d8SELinux\u7684\u8bbe\u7f6e\uff0c\u53ef\u4ee5\u6539\u53d8\u6587\u4ef6\u5939\u7684SELinux\u6743\u9650\uff1a<br \/>\nls -alZ\u67e5\u770b\u6587\u4ef6\u6743\u9650<br \/>\n\u53ef\u4ee5\u6b63\u5e38\u8bbf\u95ee\u7684\uff1adrwxr-xr-x. root root unconfined_u:object_r:usr_t:s0 html<br \/>\n\u4e0d\u80fd\u6b63\u5e38\u8bbf\u95ee\u7684\uff1adrwxrwxr-x. www www unconfined_u:object_r:default_t:s0 test<br \/>\n\u6bd4\u8f83\u4e00\u4e0b\u5c31\u53d1\u73b0\u95ee\u9898\u4e86\uff0c\u7528\u547d\u4ee4\u4fee\u6539test\u6587\u4ef6\u5939\u7684SELinux\u6743\u9650\uff1achcon -R -t usr_t test<br \/>\n\u8fd9\u6837\u5c31OK\u4e86\uff01<\/p>\n<p>\u53c2\u8003\u8d44\u6599\uff1a<br \/>\n<a href=\"http:\/\/blog.chinaunix.net\/uid-26495963-id-3300475.html\" target=\"_blank\">http:\/\/blog.chinaunix.net\/uid-26495963-id-3300475.html<\/a><br \/>\n<a href=\"http:\/\/www.codesec.net\/view\/538043.html\" target=\"_blank\">http:\/\/www.codesec.net\/view\/538043.html<\/a><br \/>\n<a href=\"http:\/\/www.2cto.com\/os\/201504\/394096.html\" target=\"_blank\">http:\/\/www.2cto.com\/os\/201504\/394096.html<\/a><br \/>\n<a href=\"http:\/\/blog.csdn.net\/u012511616\/article\/details\/52735539\" target=\"_blank\">http:\/\/blog.csdn.net\/u012511616\/article\/details\/52735539<\/a><\/p>\n<p>\u53e6\u5916\uff0c\u5982\u679cphp\u6587\u4ef6\u4e2d\u8fde\u63a5mysql\u7684\u5730\u5740\u4e0d\u662flocalhost\uff0c\u800c\u662f\u4e00\u4e2a\u7f51\u5740\u6216\u8005\u5916\u7f51\u7684IP\uff0c\u90a3\u4e48\u8fd9\u4e2a\u65f6\u5019SELinux\u53c8\u8981\u9650\u5236\u4e86\uff0c\u9875\u9762\u4f1a\u62a5\u9519\uff1aError establishing a database connection<br \/>\n\u5982\u4f55\u4fee\u6539\uff1asetsebool -P httpd_can_network_connect=1<br \/>\n\u53c2\u8003\u8d44\u6599\uff1a<a href=\"http:\/\/www.jb51.net\/article\/52581.htm\" target=\"_blank\">http:\/\/www.jb51.net\/article\/52581.htm<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u66b4\u529b\u89e3\u51b3\uff1a\u628aSELinux\u4eceEnforcing\u5207\u6362\u5230Permissive\u3002\uff08\u4e34\u65f6\u4fee\u6539setenforce Pe...<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,15329,15331],"tags":[],"class_list":["post-232","post","type-post","status-publish","format-standard","hentry","category-linux","category-nginx","category-php"],"_links":{"self":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts\/232","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=232"}],"version-history":[{"count":0,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=\/wp\/v2\/posts\/232\/revisions"}],"wp:attachment":[{"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=232"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=232"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lnmp.ivan.xin\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=232"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}