---
On Redhat based Linux, Apache2/httpd configuration files are usually based in /etc/httpd/conf/.
$vi /etc/httpd/conf/httpd.conf
# search UserDir in file which may be as below:
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disabled
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
#UserDir public_html
Now change as below:
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
UserDir disabled
UserDir enabled testuser1
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disabled" line above, and uncomment
# the following line instead:
#
UserDir public_html
Note:
UserDir disabled
UserDir enabled testuser1
Above code will enable the user directory just for user testuser1 and it will be remain disabled for all user. To enable for all user change as below:
#UserDir disabled
UserDir enabled
---------
Now, the next step is to configure public_html directory structure by removing the comment from the httpd.conf as below code.
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Order allow,deny
Allow from all
Order deny,allow
Deny from all
-----
Now, change the directory permission.
chown testuser1:testuser1 /home/testuser1/public_html
chmod 755 /home/testuser1/public_html
and at last run below command:
setsebool -P httpd_enable_homedirs true
root$service httpd restart
Update:
If you are getting error "(13)Permission denied: access to /demoproj denied" then it might be because of SELinux settings. To make it work, please check SELinux settings or run below command.
chcon -t httpd_sys_content_t /var/www/html/