Originally Posted by
somafm
I thought this was a decent idea at first; however, whenever I am not logged onto the computer, my apache2 server returns "Forbidden 403" error messages on all pages. When I log back in, everything is perfectly fine again.. so I think it has to do with this whole "encrypted home directory" feature because my web server files are stored in: /home/user/public_html/
Hi, I found a happy medium that lets me keep my encrypted home directory, while my public_html isn't encrypted.
1) Create a new directory /home/public_html. That doesn't have to be the name, but it makes it easy to know what it is.
Code:
sudo mkdir /home/public_html
2) Create a subdirectory for yourself inside /home/public_html. Note, the $USERNAME environment variable should be defined. If it isn't, just substitute your username for the variable. Lastly, change the owner/group of the directory to your username (I'm assuming your group name is the same as your user name).
Code:
cd /home/public_html
sudo mkdir $USERNAME
sudo chown $USERNAME:$USERNAME $USERNAME
3) Now put a symlink from your home directory to this directory. This is purely for your convenience. If there is a public_html directory in your home folder, make sure you migrate these files to /home/public_html/$USERNAME and then remove the directory so you can make the symlink.
Code:
cd ~
ln -s ../public_html/$USERNAME/ ./public_html
4) Now, here is the important part. The apache2 configuration must be updated. I will assume that you have not setup UserDir before (as it is not setup when you first install Apache), but if you have set it up already, you'll see what needs to be changed (one line really).
Setup the userdir configuration (I use vi, but using gedit here so everyone can edit the file):
Code:
gksudo gedit /etc/apache2/conf.d/userdir
Cut and paste the following code into this file:
Code:
UserDir /home/public_html
UserDir disabled root
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options Indexes SymLinksIfOwnerMatch IncludesNoExec
</Directory>
Save and close.
5) Setup the appropriate symlinks that enables the loading of the userdir module into apache.
Code:
cd /etc/apache2/mods-enabled/
sudo ln -s ../mods-available/userdir.* .
6) Reload the apache configuration.
Code:
sudo /etc/init.d/apache2 reload
That's it.
Bookmarks