Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Looking in /etc/apache2/apache2.conf you will see a reference to the directory, /etc/apache2/sites-enabled/. Apache will look in this directory and load any virtual host file configurations.

Warning

I am finding that the www. in front of directory names is unnecessary and harder to quickly get to folders. So will carefully remove www. from all the folder names.

Setup Virtual Hosting Directories

Setup Virtual Hosting Directories

Now we setup the directories to be used by Apache where your html files are kept.

Tip
The entire sprit of what I'm trying to do below follows least access privileges using base Linux permissions. I tried using advanced Linux permissions, ACLs, but even that technology is too limiting. However, there is a much better approach if you can use container technology as you're then limiting the entire OS experience for a user to their particular directory. I'll write this up in the future, but only if there is someone interested.

Assuming you are logged in as a member of the staff group, we will be creating groups and users with reserved ids as mentioned in the basic setup,

Code Block
languagebash
cd /opt/web
sudo mkdir www.krypton.com # Home directory for the website.
 
cd /opt/web/www.krypton.com
sudo mkdir www # Folder for static content
sudo addgroup --gid 3100 wgkryptonian # Special work group to distinguish users who should have access to the website.
 
cd /opt/web
sudo chown -R serveradmin:wgkryptonian ./www.krypton.com/
sudo chmod -R o-wx ./www.krypton.com/ # Make sure others can't change files.
sudo chown -R serveradmin.wgkryptonian ./www.krypton.com/ # Ensure setgid bit is setup so new files created will have same groups.
# Repeat for www.earth.com
cd /opt/web
sudo mkdir -p www.earth.com/www # Makes both directories with one command
sudo addgroup --gid 3101 wgearthling
sudo chown -R serveradmin:wgearthling ./www.earth.com/

...