Sunday, October 14, 2012

Hosting multiple sites with Apache and Cent OS

Hosting multiple sites with Apache and Cent OS

Assuming you have the setup Apache Web Server& CentOS installed by default

DNS Settings
Make sure your domain name pointing to the VPS/Dedicated Hosting server IP.To check login to your domain control panel check the name server and A record (probably under DNS Settings/Manage DNS menu) entries are correct.

Server Settings
Open up your vps/dedicated server console using putty login to your server as root, find your httpd.conf file under /etc/httpd/conf folder, make a backup of httpd.conf before going to make any changes using cp command
  • Change your directory as shown in figure cd /etc/httpd/conf
  • Make backup of your httpd.conf by issuing command cp httpd.conf httpd.conf.bkup
  • Make sure backup done using list file commsnd ls

Two host multiple sites with apache we can use Name based virtual hosts, or IP based virtual hosts. Here i am going to use Name based virtual hosts

To enable multiple host support you must add, or uncomment, the following line in /etc/httpd/conf/httpd.conf:

NameVirtualHost *
This sets up Apache to accept the hosts.

If  i am going to host two sites named & then i have to create two directories under /var/www


then i have to change/add my httpd.conf should have the following lines 

<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot "/var/www/"
    ServerName    ServerAlias
    ErrorLog logs/error_log
    CustomLog logs/sitea_access_log combined

<VirtualHost *:80>
    ServerAdmin root@localhost
    DocumentRoot "/var/www/"
    ErrorLog logs/in_error_log
    CustomLog logs/siteb_access_log combined

Restart the Apache HTTP Server daemon
service httpd restart

And you are done!.


ajay teja said...

Good work…unique site and interesting too… keep it up…looking forward for more updates.Good luck to all of you and thanks so much for your hard-work.
Language Interpretation Services, Voiceover Bangalore

cyber news said...

Indian Cyber Army’s most awaited internship is live now. Rush to register for Summer Internship 2018 on “ Ethical hacking” and book your seats before it runs out.Candidates have to get themselves registered to be a part of this Internship program. As career in ethical hacking is most in demand.

devidnayana said...

I am very happy when read this blog post because blog post written in good manner and write on
good topic. Thanks for sharing valuable information.

School Information Management System,
Online Fee Payment Integration
College Management System


cyber news said...

thanks for sharing the more valuable information.
Indian Cyber Army credibility in Ethical hacking training & Cybercrime investigation training is acknowledged across nation as we offer hands on practical knowledge and full assistance with basic as well as advanced level ethical hacking & cybercrime investigation courses. The training is conducted by subject specialist corporate professionals with wide experience in managing real-time ethical hacking/ cyber security projects. Indian Cyber Army implements a blend of academic learning and practical sessions to give the candidate optimum exposure.Ethical hacking training ,
Ethical hacking course