HTTP: Configure a virtual host

Share this link

Install the “Web Server” package group:

# yum groupinstall -y "Web server"

Edit the /etc/httpd/conf/httpd.conf file and uncomment the following directive:

#NameVirtualHost *:80

At the end of the same file, uncomment the following stanza:

#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

Don’t forget to replace dummy-host.example.com by the name of your webserver.

Check the validity of the /etc/httpd/conf/httpd.conf file:

# httpd -t
# service httpd configtest

Check the virtual host(s) configuration:

# httpd -S
# httpd -D DUMP_VHOSTS

Add a new rule to the firewall:

# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

Save the firewall configuration:

# service iptables save

Activate the httpd service at boot:

# chkconfig httpd on

Start the httpd service:

# service httpd start

Check the httpd service:

# yum install -y elinks
# elinks http://localhost
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

Leave a Reply

Upcoming Events (Local Time)

There are no events.

RHCSA7: Task of the day

Allowed time: 10 minutes.
Create an EXT4 file system mounted by UUID in /etc/fstab under /vol based on a logical volume of 28 logical extents.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a default secure MariaDB database called maria with a user named muser with all privileges.

Follow me on Twitter

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...