Apache Virtual Host Class Activity - savannahc502/SavC-TechJournal-SEC260 GitHub Wiki

Virtual Hosts - Allow multiple websites to run on one Apache Server (and use 1 IP address)

I. Set up Apache for Virtual Hosts

  • Start the Rock Linux Machine (10.0.17.50 in this case)
  • mkdir /var/www/vhosts > creating the vhosts webroot

Create the root for your first Virtual Host site

  • cd /var/www
  • cd vhosts
  • mkdir ciak.com
  • mkdir html

Create simple file with "Hello for your-last-name.com" as the index.html file in that directory

  • cd /html
  • vi index.html
<html>
  <head>
    <title>
      Hello Ciak
    </title>
  </head>
  <body>
    Hello Ciak's page
  </body>
</html>

Create Apache configuration file for Virtual host.

  • Add following content into /etc/httpd/conf.d/ciak.conf file.
  • Apache will automatically load all conf files from conf.d directory.
<VirtualHost *:80>
        DocumentRoot "/var/www/vhosts/ciak.com/html"
        ServerName ciak.com
        ServerAlias www.ciak.com

        <Directory /var/www/vhosts/ciak.com/html>
                AllowOverride All
                Options Indexes FollowSymLinks
                Require all granted
        </Directory>
</VirtualHost>

<image

  • Restart httpd sudo systemctl restart httpd

II. Set up Second Virtual Host

  • Repeat steps 4-6, but use your First Name instead of your last name

This is what the tree for /var/www should look like now: image


III. Connect to the different sites

Editing Host File

  • You can do update the DNS names in the local Hosts file:
    • On Kali: Edit the /etc/hosts file
    • On Windows: C:\Windows\System32\drivers\etc\hosts
      • Keep getting error when attempting to edit the windows file, but you don't actually need it since it is not in the scope of the assignment

Add the following at the end (server IP) (default is port 80)

10.0.17.50     savannah.com
10.0.17.50     ciak.com
  • Save the file.

Testing Telnet on Kali for ciak.com and savannah.com

image

image


Testing Browser on Kali for ciak.com and savannah.com

image


Deliverables: cat outputs from your successful vhost config files

HTML Files:

image

image

Configuration Files:

image

⚠️ **GitHub.com Fallback** ⚠️