How to create virtual hosts on Apache (httpd) on CentOs 7



Free Linux Cheat Sheet Download: http://eepurl.com/dkRNM9

Using virtual hosts on Apache allows you to host multiple websites on one server. In order for virtual hosts to function correctly you will need to insure that you have DNS set up correctly for your sites. If you are following this tutorial for test purposes you can reference this video on how to manually set DNS on a Centos Server:

If you need to know how to install apache on CentOs you can reference this video:

The commands that you need to follow this video can be found here:

How to create virtual hosts on Apache (httpd) on CentOs 7


source
centos 7

Devin BARTON

Devin BARTON

I am an avid Linux lover and open source enthusiast. I use Ubuntu and believe in sharing knowledge. Apart from Linux, I love classic detective mysteries.

19 thoughts on “How to create virtual hosts on Apache (httpd) on CentOs 7

  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    Hi Darren, I followed both your tutorials on hosts and virtual hosts.. but I am still having issues. If I type my server's ip address it gets me automatically to site 1… but if I type the http://www.site1.com or http://www.site2.com, i get the error that the site can't be reached… I have setup my hosts file to point to my server's ip address with the 2 names.. what am I doing wrong?

    Marc.

    Reply
  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    Thanks – so what is vhosts folder for? You didn't use www/vhosts. Bit lost.

    Reply
  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    It's not working… Setenforce 0 not repair problem with job.. In httpd.conf j change sites-enabled to sites-available and serwer started however site1.com like site2.com not working : (

    Reply
  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    unfortunately display the centos default page.I have change dns on my system32/hosts restart apache and still the same.what am i doing wrong?

    Reply
  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    Hi, I've recently had this as a beginner task to a new job I've started. My task involves making the second site use port 4445. How can this be done? Every time I include "Listen 4445" in the httpd.conf file both sites stop working. If I change the site2.com.conf file then it just shows site1's content when going to site2.com for example. Not sure what I'm not seeing here.
    Thanks for the video btw Darren, found your channel when researching my issue earlier today, went to reddit to see what I could find there and found your post about making Centos videos, they're very informative from one Irish lad to another, its appreciated!

    Reply
  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    All good, but, how can I access from other sistem? I'm doing this on VMWare, but I can't get access to the sites from the browser on other virtual machine.
    Great video.

    Reply
  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    I am getting "ln: failed to create symbolic link ‘/etc/httpd//Sites_Enabled/site_Two.com.conf’: No such file or directory", Do I need to create the conf files before running this script?

    Reply
  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    Darren, I edited /etc/hosts and was able to see site1 & site2. Awesome, thank you again. Keep the videos coming.

    Reply
  • Avatar
    September 13, 2020 at 10:18 am
    Permalink

    Darren thanks for the tutorial. I was able to follow the instructions to set up vhost, however I am unable to view site1.com and site2.com. When I put my local IP for the website server (192.168.0.1), it says "This is site1". Any tips on what to fix? This is the second time I am doing this again with a fresh CentOS7 box and I just can't get the padlock to come up.
    Thanks for the video

    Reply

Leave a Reply