Configure Apache for public_html
Apache can be configured to use a folder ( usually public_html ) in any user's home directory. This is relatively straight forward if you don't mind editing the httpd.conf file and changing a few file permissions...
A complete guide can be found here.
Step 1 - Change httpd.conf
In fedora and red-hat the correct configuration is already there. It's just commented out.
Step 3 - Ensure the correct access permissions are set on the home directory
As normal user in home directory
All Done!
A complete guide can be found here.
Step 1 - Change httpd.conf
In fedora and red-hat the correct configuration is already there. It's just commented out.
#> vim /etc/httpd/conf/httpd.conf#Step 2 - Reload the httpd.conf
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# The path to the end user account 'public_html' directory must be
# accessible to the webserver userid. This usually means that ~userid
# must have permissions of 711, ~userid/public_html must have permissions
# of 755, and documents contained therein must be world-readable.
# Otherwise, the client will only receive a "403 Forbidden" message.
#
# See also: http://httpd.apache.org/docs/misc/FAQ.html#forbidden
#
#
# UserDir is disabled by default since it can confirm the presence
# of a username on the system (depending on home directory
# permissions).
#
#UserDir disable
#
# To enable requests to /~user/ to serve the user's public_html
# directory, remove the "UserDir disable" line above, and uncomment
# the following line instead:
#
UserDir public_html
#>service httpd reloadStep 2 - Ensure that selinux is enabled for user_dir
#> setsebool httpd_enable_homedirs true
Step 3 - Ensure the correct access permissions are set on the home directory
As normal user in home directory
~> chmod a+x ~Step 5 - Create the public_html directory
~> mkdir public_htmlStep 6 - Set the selinux type label for public_html
~> chcon -t httpd_sys_content_t public_htmlStep 7 - Create a web page or php script in your public_html folder and browse to it by:
http://localhost/~david/phpinfo.php
All Done!