How Can We Help?

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started

How to host a domain on centos 7

Table of Content
How to host a domain on centos 7


In this article, you will learn how to host a domain on centos 7.

If you wish to host many domains on your server, you must configure the webserver with the appropriate hosts. Thus, your server can send unique content based on the request. This guide will teach you how to setup virtual Apache hosts on CentOS 7.

Beginning with yum update yum update -y

1. Installing Apache

# yum -y install httpd

# systemctl enable httpd.service
# systemctl start httpd

# systemctl status httpd

To see if Apache is already operating, type your IP address in the browser. This is how the page ought to appear:


2. Creating Directory Tree

1. Data for websites is stored in a directory structure. First, use the following command to change the working directory to /var/www:

# cd /var/www/

2. All of your virtual hosts should have their own document root.

# mkdir -p
Replace with your domain name.

3. Create a path that Apache may use to reach the directory. Execute the chown and chmod commands to make the necessary changes to the ownership and permissions of the entire web directory.

# chown -R apache:apache /var/www/
# chmod -R 755 /var/www

Apache now has the necessary rights to add new directories and serve content in response to incoming queries.

3. Creating a Demo Page

If you're using Apache virtual hosts, you should create a demonstration page. You can see if the host is up and running before transferring your website files. The procedure is as follows:

1. To make an index.html file for the public html folder at, use the vi editor.

# vi

2. Paste the following content to the file:

    <title>This is a test page</title>
    <h1>Hello Microhost</h1>

3. To save the file, press escape colon wq

4. Creating the Virtual Host

1. Make a fresh virtual host configuration file (.conf) in the Apache installation root:

# vi /etc/httpd/conf.d/

2. Insert the following content into the .conf file:

<VirtualHost *:80>
    DocumentRoot /var/www/
    ErrorLog /var/www/
    CustomLog /var/www/ combined

3. To save the file, press escape colon wq 

In the preceding example, we tell Apache that we will use port 80 for communication and that the virtual host's name is Furthermore, we specify directories for website files (document root) and error logs.

4. Restart Apache for the changes to take effect:

# systemctl restart httpd.service

That's all there is to it; you've just created an Apache virtual host for your domain! Now, in your browser, enter your IP address and you should see the "Hello Microhost" text from the demo page we created earlier.

Thank You 🙂

Special Offer

Deploy your Cloud Server now and get $100 in Free Credits!

Get Started
Table of Contents