Web Services: Configuring a Virtual Host on Apache

10 minutes
  • 2 Learning Objectives

About this Hands-on Lab

Apache Virtual Hosts are used when you want to host multiple websites on a single server. It’s useful to lower your server footprint and to make better use of the available hardware. In this lab, you’ll be able to work with different methods of declaring Virtual Hosts.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Configure and Test an IP-Based Virtual Host Using Port 80
  1. Because we’re configuring Apache, elevate to root.
  2. Remove the Listen configuration option from /etc/httpd/conf/httpd.conf.
  3. Create a new file in /etc/httpd/conf.d/DadCorp.conf that contains permission for Apache to access the /opt directory and the VirtualHost definition.
  4. Restart Apache, and verify your configurations work.
Configure and Test an IP-Based Virtual Host Using Port 8080
  1. Modify the /etc/httpd/conf.d/DadCorp.conf file to include a new Listen directive with the correct port.
  2. Set up a new VirtualHost definition that includes the right port.
  3. Restart Apache, and verify your configurations work.

Additional Resources

You have just started working at DadCorp, a new start-up providing a subscription service that emails dad jokes to customers. The datacenter has mostly web servers that contain the sign-up forms.

DadCorp is expanding and needs to revamp its infrastructure. As part of doing so, they're changing the setup of their web servers to use VirtualHosts instead of just using the main Apache DocumentRoot.

Set up an Apache VirtualHost to use /opt/website as the DocumentRoot using an IP-based VirtualHost, with a server name of www.dadcorp.com.

You also received a second ticket. To enable testing with some new load balancers, another VirtualHost is needed. It should be identical to the first but run on port 8080 instead.

Log in to the Linux server using the provided credentials. Once logged in, become the root user, using sudo -i.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?