Virtual Hosting in Apache

Virtual Hosting is a term used to refer the practice of running multiple websites on a single machine.Virtual hosts can be IP-based, meaning that you have a different IP address for every web site, or name-based, meaning that you have multiple names running on each IP address. The fact that they are running on the same physical server is not apparent to the end user.

The following commands are tested on RedHat and CentOS.

Add the following lines in your configuration file
# vi /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin root@server.example.com
ServerAlias server2.example.com
DocumentRoot /home
ServerName storage.estuate
ErrorLog logs/deepak.example.com.log
CustomLog logs/deepak.example.com.access_log
</VirtualHost>
Here "*" signifies your apache server will listen to any IP you have used for web server configuration on your machine. You should make an habbit of using proper IP or name instead of "*".

ServerAdmin ==> sets the contact address that the server includes in any error messages it returns to the client.If the httpd doesn't recognize the supplied argument as an URL, it assumes, that it's an email-address and prepends it with mailto: in hyperlink targets. However, it's recommended to actually use an email address.

ServerAlias ==> This directive sets the alternate names for a host.

ServerName ==> This directive sets the request scheme, hostname and port that the server uses to identify itself. This is used when creating redirection URLs.

DocumentRoot ==> This directive specifies the root directory of the files you want to be visible on your web server

Adding some more features to your virtual hosts
# vi /etc/httpd/conf/httpd.conf
<VirtualHost *:80>
ServerAdmin root@server.example.com
ServerAlias server2.example.com
DocumentRoot /home
ServerName storage.estuate
<Directory /home/deepak/mypage.html>
AllowOverride None
Order Deny,Allow
Deny from All
</Directory>
</VirtualHost>
AllowOverride None will disable the access to .htaccess file

By default users are allowed to access all the directories inside the document root on the web server. To override this rule we use the following directive
<Directory /home/deepak/mypage.html>
Order Deny,Allow
Allow from all
</Directory>
You can check one example of virtual hosting with all the above directives used in the following post
yum configuration using apache server

Follow the below links for more tutorials

2 thoughts on “Virtual Hosting in Apache”

  1. Hello friends,
    Now you can send 5000 FREE emails per month using our email marketing servers with multiple IPs to get your campaign to
    inbox.Get great inbox deliveries and land your 95% emails to inbox.
    With our userfriendly and beautiful web-app you would be able to track every movement of your campaign. You would be able
    to see the users who have opened, clicked, unsubscribed, bounced and marked as spam.
    You can register here for your FREE account: client.hostwiser.com/cart.php?a=view
    HURRY!!
    * You must have access to your own opt-in list of your subscribers.You must be compliant with the ICANN-SPAM ACT of anti
    spamming.We do not sell email lists.

    Reply
  2. EmailOcean is a brand new platform to cater to your email marketing needs.
    It has been launched under the patronage of KOONK TECHNOLOGIES PVT. LTD. and is one of a kind platform for email marketing.
    There is not point in harping on about the advantages of email marketing,as at this point in time,email marketing is the sole way of marketing or promoting your product,service or message in an efficient and quick manner.
    EmailOcean provides you with the following advantages:
    Highly Economical: It provides promotional emailing at an amazingly low rate of $0.10 per 1000 emails. The customer only pay for what is utilised. This is the lowest price available for mass mailing.
    Web App to create and track campaign: The brilliance of EmailOcean lies in it making the process easier and faster for the customer,as compared to Amazon and Sendgrid, EmailOcean has a beautiful Web-app which makes creating and sending the campaign a lot more easier. Using this web-app one can also send and track their campaigns and get detailed analytics.You can see the users who have opened, clicked, unsubscribed and bounced.
    Inbox Deliveries: Their inbox delivery rate is phenomenal.
    Excellent Support: They also provide a support staff that is available at your beck and call 24*7.
    As of now,the registrations are open by invitation but register yourself with the website and keep self updated as to when they are open to all or for your surprise invitation code.

    Reply

Leave a Comment