Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated to new Confluence 3.5 bash option for code display.

...

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
langlanguagehtmlbash
cd /home
sudo mkdir www.krypton.com # Home directory for the website.
sudo mkdir www.earth.com

cd /home/www.krypton.com
sudo mkdir www # Folder for static content

cd /home/www.earth.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.
sudo addgroup --gid 3101 wgearthling

cd /home

sudo chown -R serveradmin:wgkryptonian ./www.krypton.com/
sudo chown -R serveradmin:wgearthling ./www.earth.com/

sudo chmod -R 775 www.krypton.com # Only svradm and users in the kryptonian group can manage. Apache(other's) still need to be able to read and browse.
sudo chmod -R 775 www.earth.com

Now we create users that will have access to their respective websites,

Code Block
langlanguagehtmlbash
sudo useradd -d /home/kalel -m -u 2500 -G wgkryptonian -c "Client" -s /bin/bash kalel # Add user kalel with additional group and make the user's home directory
sudo useradd -d /home/jorel -m -u 2501 -G wgkryptonian -c "Client" -s /bin/bash jorel

sudo passwd kalel
sudo passwd jorel

sudo useradd -d /home/loislane -u 2502 -m -G wgearthling -c "Client" -s /bin/bash loislane
sudo useradd -d /home/jimmyolsen -u 2503 -m -G wgearthling -c "Client" -s /bin/bash jimmyolsen

sudo passwd loislane
sudo passwd jimmyolsen

...

Use the default virtual host file as a template

Code Block
langlanguagehtmlbash
cd /etc/apache2/sites-available
sudo cp default www.krypton.com
sudo cp default www.earth.com

sudo Edit www.krypton.com and remove all the extra lines and modify the matching lines,

Code Block
langlanguagehtml
<VirtualHost *:80>
       ServerAdmin webmaster@localhost

       ServerName www.krypton.com
       ServerAlias krypton.com

       DocumentRoot /home/www.krypton.com/www

    #   # This restrictive a precedence forprecedence for ALL directory blocks.
       <Directory />
              Options FollowSymLinks
              # This prevents use of .htaccess
              AllowOverride None   None      
    </Directory>

    #   # Main location of static content for the websites.
       <Directory /home/www.krypton.com/www/>
              Options +MultiViews
               Order Allow,Deny
               Allow from all
       </Directory>

       ErrorLog /var/log/apache2/www.krypton.com.error.log

       # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
       LogLevel warn

       CustomLog /var/log/apache2/www.krypton.com.access.log combined

</VirtualHost>

...

Just because you created the virtual host does not mean it is enabled. To enable the virtual hosting,

Code Block
langlanguagehtmlbash
sudo a2ensite www.krypton.com # enable a virtual host
sudo a2ensite www.earth.com # enable a virtual host

...

Ubuntu already added these directives as shown,

Code Block
langlanguagehtmlbash
tpham@krypton:/etc/apache2$ find . -type f | xargs grep -i listen
./ports.conf:Listen 80
./ports.conf:    Listen 443
tpham@krypton:/etc/apache2$ find . -type f | xargs grep -i namevirtualhost
./ports.conf:NameVirtualHost *:80
./ports.conf:    # NameVirtualHost statement here
tpham@krypton:/etc/apache2$

...