Appache to access user home directories

Table of Contents

Issue

  • How to enable appache to access user home directories?

  • How to use SELinux Booleans to control appache to access user home directories?

Solution

  • Make sure Apache web server are installed correctly

# systemctl status  httpd
  • Enable the Apache feature that permits users to publish web content from their home directories

# vim /etc/httpd/conf.d/userdir.conf
# grep '^ *UserDir' /etc/httpd/conf.d/userdir.conf
    UserDir public_html
  • Restart httpd

# systemctl restart httpd
  • Create some web content that is published from a user’s home directory.

$ mkdir ~/public_html
$ echo 'SUCCESS' > ./public_html/ping
$ chmod 711 ~
  • Access web content ping

# curl http://10.66.192.120/~kylin/ping
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>403 Forbidden</title>
</head><body>
<h1>Forbidden</h1>
<p>You don't have permission to access /~kylin/ping
on this server.</p>
</body></html>
  • use the getsebool command to see if there are any Booleans that restrict access to home directories

# getsebool -a | grep home
  • Use setsebool to enable home directory access persistently.

# setsebool -P httpd_enable_homedirs on
  • Access web content ping

# curl http://10.66.192.120/~kylin/ping
SUCCESS

results matching ""

    No results matching ""