User Tools

Site Tools


linux:apache2-user-directories

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

linux:apache2-user-directories [2019/01/21 11:25] (current)
seanburns created
Line 1: Line 1:
 +<​markdown>​
 +# Apache2 User Directories
 +## Date: Mon 05 Nov 2018
  
 +## Reset httpd.service to port 80
 +
 +Last week you changed the *Listen* directive to port 8080. Change it back to
 +port 80 by editing ``/​etc/​httpd/​conf/​httpd.conf``. (Be sure to login as root or
 +use the ``sudo`` command, as appropriate.)
 +
 +```bash
 +# cd /​etc/​httpd/​conf/​
 +# nano httpd.conf
 +```
 +
 +After changing the configuration file, close ``nano`` (or whatever text editor
 +you're using) and then restart ``httpd.service`` and see if it's successfully
 +running on port 80.
 +
 +```bash
 +# systemctl restart httpd.service
 +# systemctl status httpd.service
 +# w3m http://​127.0.0.1/​
 +```
 +
 +## Enable userdir (``$HOME/​public_html`` sites)
 +
 +Edit the ``userdir.conf`` file.
 +
 +```bash
 +# cd /​etc/​httpd/​conf.d/​
 +# nano userdir.conf
 +```
 +
 +Make the following changes:
 +
 +- ``UserDir disabled`` to ``UserDir enabled``
 +- Uncomment line ``UserDir public_html``
 +
 +After saving and exiting, restart ``httpd.service``:​
 +
 +```bash
 +# systemctl restart httpd.service
 +```
 +
 +## Tasks
 +
 +1. Exit out of root account
 +2. Go to your regular user's home directory
 +3. Make a directory titled ``public_html``
 +4. Change home directory permissions to 711
 +5. Change ``public_html`` directory permissions to 755
 +
 +## SELinux
 +
 +Now, because of SELinux, we need to set some SELinux switches. Using ``sudo``
 +or logging in as ``root``:
 +
 +```bash
 +# setsebool -P httpd_enable_homedirs true
 +# chcon -R -t httpd_sys_content_t /​home/​sean/​public_html
 +```
 +
 +In the last line above, replace ``/​home/​sean/​public_html`` with the correct
 +path for your regular user (i.e., you're not *sean*). Exit out of root if you
 +need to.
 +
 +## Test
 +
 +Now test to see if your ``public_html`` site is operational by simply visiting
 +the site. For me, I use the following command:
 +
 +```bash
 +$ cd ~/​public_html/​
 +$ echo "<​p>​Hello world</​p>"​ >> index.html
 +$ w3m http://​127.0.0.1/​~sean
 +```
 +</​markdown>​
linux/apache2-user-directories.txt ยท Last modified: 2019/01/21 11:25 by seanburns