Virtual Hosts Related Pointers

There are occasions when you would like to have some meaningful urls like http://projectA or http://projectInfinite on the browser rather than always typing to the point folder. Dont you think its weird to remember the whole length or see the whole long shot like ‘http://localhost/projectA’ or ‘http://localhost/projectInfinite’ etc,

So, let me give some quick insights, might not be full , might be too brief but definitely would serve the purpose for a quick understanding and work around, especially when you dont have lots of time to read contents to get some basic ideas.
——————————————————————————
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/projectA
ServerName localhost:80
ErrorLog logs/projectA-error_log
CustomLog logs/projectA-access_log common
</VirtualHost>

<VirtualHost *:800>
#    ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/projectB
ServerName localhost:800
ErrorLog logs/projectB-error_log
CustomLog logs/projectB-access_log common
</VirtualHost>

<VirtualHost *:567>
#    ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /var/www/html/harish/
ServerName localhost:567
ErrorLog logs/harish-error_log
CustomLog logs/harish-access_log common
</VirtualHost>
—————————————————————————-
Now as you are done with till here, go to the top of the conf file and find for the following section of content. Did you observe the 80, 800, 567 above.These are the ports that web server listens to serve request and so you need to tell specifically( if mentioned in virtualhost) to listen to these ports as below , in your httpd.conf file.
—————————————————————————-
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80
Listen 800
Listen 567

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: