How to configure Apache Server (http) with Virtual Hosting in CentOS 7, Redhat 7, Fedora - Linux tech Solutions

Share on :

How to configure Apache Server (http) with Virtual Hosting in CentOS 7, Redhat 7, Fedora

Http/Apache is used to host a single website or multiple website on system with static IP address.The Apache HTTP Server, is free and open-source cross-platform web server software, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation.

Virtual hosting is a method for hosting multiple domain names (with separate handling of each name) on a single server (or pool of servers). This allows one server to share its resources, such as memory and processor cycles, without requiring all services provided to use the same host name. The term virtual hosting is usually used in reference to web servers but the principles do carry over to other internet services.

One widely used application is shared web hosting. Shared web hosting prices are lower than a dedicated web server because many customers can be hosted on a single server. It is also very common for a single entity to want to use multiple names on the same machine so that the names can reflect services offered rather than where those services happen to be hosted.

Package httpd

Ports :-

http - 80

Selinux context httpd_sys_content_t

Main Configuration filfe  /etc/httpd/conf/httpd.conf

Document root   /var/www/html

Server Configuration :-

To configure Apache server we must have an static ip.

1 )first of all we will install the httpd package :-

[[email protected] ~]# yum install httpd

2 )Now we will create our own configuration file in /etc/httpd/conf.d

You can create with the configuration file with any name but the file extension must be .conf .

[[email protected] ~]# vim /etc/httpd/conf.d/web.conf

In this configuration file you have to give the following parameters:-

 3 ) Now we will create a directory for our second website.

[[email protected] ~]# mkdir   /var/www/virtual

4 )Now you need to go the /etc/hosts file.

[[email protected] ~]# vim /etc/hosts

#[your IP]       [your Website name]

5 )Now we will go to the document root and create a index.html file.

[[email protected] ~]# vim /var/www/html/index.html

My First Web Site

Same we will do for the second website.

[[email protected] ~]# vim /var/www/virtual/index.html

My Second Web Site

5 )Now we will start the httpd service.

[[email protected] ~]# systemctl start httpd
[[email protected] ~]# systemctl enable httpd

6 )Now Apply the Firewall rule.

[[email protected] ~]# firewall-cmd   --permanent   --add-service=http
[[email protected] ~]# firewall-cmd   --reload

7 )Now our websites are ready we will open it in firefox browser

[[email protected] ~]# firefox
[[email protected] ~]# firefox

The Video below is a step by step guide.

Share on :

You may also like...

4 Responses

  1. Rajani says:

    it's very interesting Blog!! Thanks for sharing
    Docker Online Training
    Kubernetes Online Training
    Kubernetes Training in Hyderabad
    Docker and Kubernetes Training in Hyderabad

  2. Hawt rajpoot says: offers high quality DMCA Ignored Hosting.

  3. Web Hosting in Malaysia says:

    Thank you so much for this awesome information.
    Web Hosting in Malaysia

  4. web hosting in Pakistan says:

    Thanks for providing useful information
    Web Hosting in Pakistan

Leave a Reply

Your email address will not be published. Required fields are marked *