{"id":1647,"date":"2013-05-14T15:16:31","date_gmt":"2013-05-14T15:16:31","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=1647"},"modified":"2013-05-14T15:16:31","modified_gmt":"2013-05-14T15:16:31","slug":"centos-apache-folder-outside-varwwwhtml","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=1647","title":{"rendered":"Centos Apache folder outside \/var\/www\/html"},"content":{"rendered":"<p>This article briefly describes how to move virtual hosts outside the standard \/var\/www\/html directory in CentOS 6.x.\u00a0By default SELinux in CentOS does not allow the httpd process to access files outside the standard \/var\/www\/html directory.<\/p>\n<p>One side effect of not having the access permission is that\u00a0properly configured virtual hosts\u00a0resolve to the default directory without any errors in server&#8217;s log files. This\u00a0makes it difficult to troubleshoot without installing additional tools.<\/p>\n<h3>What Is SELinux?<\/h3>\n<p>SELinux is an access control implementation for the Linux kernel. The root user can define rules in user space. If the Linux kernel has been compiled with SELinux support, those rules will be adhered to by the kernel.<\/p>\n<h3>How to Check if SELinux is Enabled?<\/h3>\n<p>With the following commands it is possible to check if the SELinux mechanism is actively enforcing the security rules:<\/p>\n<p><i><b>sestatus<\/b>\u00a0&#8211; shows\u00a0<\/i><i>the status of a system running SELinux<\/i><\/p>\n<p>The ls command provides means to display the security context:<\/p>\n<p><b><i>ls -dZ \/www\/directory-name<\/i><\/b><\/p>\n<p>For a typical directory the result will look similar to:<\/p>\n<p><b><i>unconfined_u:object_r: default_t :s0<\/i><\/b><\/p>\n<h3>Granting SELinux Access<\/h3>\n<p>In order to allow access we add the httpd security context:<\/p>\n<p><b><i>unconfined_u:object_r: httpd_sys_content_t :s0\u00a0<\/i><\/b><\/p>\n<p><b><i>chcon -t httpd_sys_content_t \/www\/test<\/i><\/b><\/p>\n<p>Normally all sub-directories will inherit the new context\u00a0automatically. For existing files keep in mind to apply the change recursively.<\/p>\n<h3>Disabling SELinux Enforcement<\/h3>\n<p>For local development setup it is possible to disable the SELinux rule enforcement in the \/etc\/sysconfig\/selinux configuration file. For production environments disabling the access control is probably not recommended.<\/p>\n<p>Configuration File:\u00a0<b>\/etc\/sysconfig\/selinux<\/b><br \/>\n<b><i><br \/>\n<\/i><\/b><i># SELINUX= can take one of these three values:<\/i><br \/>\n<i># enforcing &#8211; SELinux security policy is enforced.<\/i><br \/>\n<i># permissive &#8211; SELinux prints warnings instead of enforcing.<\/i><br \/>\n<i># disabled &#8211; SELinux is fully disabled.<\/i><br \/>\n<b><i>SELINUX=enforcing<\/i><\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This article briefly describes how to move virtual hosts outside the standard \/var\/www\/html directory in CentOS 6.x.\u00a0By default SELinux in CentOS does [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1647","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1647","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1647"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1647\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1647"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1647"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1647"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}