My server information is Show
I am trying to configure virtual host for 2 different sites: biz.example.com and pin.example.com which are hosted on the same server. There are 2 different folders located under 'var/www/html/' named 'biz' and 'pin' with their respected project files for the above mentioned 2 websites. I am trying to configure it on the below way. Within /etc/hosts below configuration
xxx.xxx.xxx.xxx is replaced by the server IP address. Within /etc/httpd/conf/httpd.conf
Now, under /etc/httpd/sites-available there are biz.conf and pin.conf file. I also have the folder sites-enabled under /etc/httpd which has 2 files that points to the biz.conf and pin.conf of sites-available folder using the below command
biz.conf has the followings
And the configuration within pin.conf file is mentioned as
On this setup, if i try to access http://biz.example.com/ , the correct website (biz website) is loading. But if i try to access http://pin.example.com/ , then also biz website is loading instead of pin website. Multiple configuration is not working together. I also tried to merge the virtual configuration of biz.conf and pin.conf within a single file, biz.conf, but it didn't work as well. Mar 29, 2022 Edgaras G. 2min Read If you want to host more than one domain on your server, you need to create corresponding hosts on the webserver. That way, your server can deliver different content for different requests. In this tutorial, you will learn how to create Apache virtual hosts on CentOS 7. 1. Installing ApacheBefore we begin, make sure that you have root access to your VPS or server using SSH connection. In Hostinger, the login credentials are located in the Servers tab of hPanel.
2. Creating Directory Tree
Apache now has the required access to create additional directories and serve content for incoming queries. 3. Creating a Demo PageIt is recommended to make a demo page for your Apache virtual hosts. This way, you can check whether the host is working before you actually move your website files. Here’s how you do it:
4. Creating the Virtual Host
That’s it, you have just created an Apache virtual host for your domain! Now try to access the host and you should see the “It works!” text from the demo page we made earlier. ConclusionYou have learned how to create an Apache virtual host in four easy steps. To summarize, let’s take a look at them once again:
We hope this tutorial is useful. Feel free to comment below if you have any questions! Edgaras is a veteran server administrator at Hostinger. He makes sure that every server runs at full throttle and has all the latest technological advancements. When he's not working, Edgaras enjoys skiing and exploring the world. What is the latest version of Apache for CentOS 7?Apache httpd 2.4.54 Released 2022-06-08
This latest release from the 2.4.x stable branch represents the best available version of Apache HTTP Server.
What is VirtualHost in Apache server?The term Virtual Host refers to the practice of running more than one web site (such as company1.example.com and company2.example.com ) on a single machine.
How do I host multiple websites on CentOS 7?How to Configure Apache Virtual Hosts on CentOS 7. Step 1: Set Up Apache. Apache will be configured to host multiple sites out of the gate, so there is not much to do here. ... . Step 2: Add Document Roots. We now need some domains to add to Apache. ... . Step 3: Add Virtual Host Files. ... . Step 4: Test And Restart Apache.. How do I set up a name based VirtualHost?Table of Contents. Introduction.. Requirements.. Create the directory structure.. Create test web pages for each virtual host.. Set up ownership and permissions.. Create virtual host configuration files.. Test the virtual hosts.. |