Quick steps to set it up (I assume you have apache installed):
- login as root
1# su - edit userdir.conf
1# nano /etc/httpd/conf.d/userdir.conf
123456789101112131415161718192021222324252627282930313233343536## 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.#<IfModule mod_userdir.c>## 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</IfModule>## Control access to UserDir directories. The following is an example# for a site where these directories are restricted to read-only.#<Directory "/home/*/public_html">AllowOverride FileInfo AuthConfig Limit IndexesOptions MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec#Require method GET POST OPTIONSRequire all granted</Directory> - restart Apache
1# systemctl restart httpd.service - setup your directory
as normal user enter:
1234# mkdir /home/your_username/public_html# chmod 711 /home/your_username# chown your_username:your_username /home/your_username/public_html# chmod 755 /home/your_username/public_html - if you use SELinux as root enter:
12# setsebool -P httpd_enable_homedirs true# chcon -R -t httpd_sys_content_t /home/your_username/public_html - create simple html page
1# nano /home/your_username/public_html/index.html
enter this:
12345<html><body>Hello!</body></html> - change ownership of file
1# chmod 644 /home/your_username/public_html/index,html - start your browser and enter this address:
1http://localhost/~your_username/
and voila! 😉
Thanks for the article, Dominik! The selinux commands that you included helped me to finally resolve my problem