Apache Virtual Host Class Activity - Hsanokklis/2023-2024-Tech-journal GitHub Wiki

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

Set up Apache for Virtual Hosts

  • Start ROCKY
  • Take note of IP address (10.0.17.23)
  • Create vhosts webroot /var/www/vhosts as a directory
  • Create the root for your first virtual host site
    • Create directory /var/www/vhosts/sanokklis.com/html
    • Create a simple file with Hello for your sanokklis.com as the index.html file in that directory (/var/www/vhosts/sanokklis.com/html/index.html

image

image

Create Apache Configuration file for Virtual host

/etc/httpd/conf.d

image

TROUBLESHOOTING: I wasn't able to restart my apache server, and I kept getting an error saying "code=exited". I found a command to check the Apache configuration files ---> apachectl configtest

When I ran this command I was prompted with syntax errors in my configuration file that I just set up, and was able to fix those and get apache running. My big error was that I didn't put a space between the first virtual host and *80

Set up Second Virtual Host

Repeat the step above and set up a second virtual host using first name instead of last name.

hannelore.com Directory set up

image

editing /etc/hosts in kali

image

Telnet sanokklis.com

image

Telnet hannelore.com

image

Browser Domain search for sanokklis.com

image

Browser Domain search for hannelore.com

image

come back later

image

image

image

image