LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > dinakumar12
User Name
Password

Notices


Rate this Entry

Name based Web server in ubuntu 9.10 server

Posted 05-09-2010 at 01:49 PM by dinakumar12
Updated 05-11-2010 at 09:51 AM by dinakumar12

Name based webserver.

We can configre webserver using apache in linux.This webserver is of two types one is name based and the other one is ipbased.

In name based webserver we can have more number of web pages for single ip address.Where as, in ip based we can have only one webpage for one ip address.

But people prefer namebased webserver as it reduces the cost of puchasing extra ipaddresses from their ISP.

Before configuring named based webserver we have to configure multiple Domains for our single ip.

Visit http://dinakumar12.wordpress.com for configuring multiple domains for single ip.

The first step in configuration of apache web server includes the installation of apache2 package.


sudo apt-get install apache2

Assume that,we already have three domains configured (1) www.example1.com
(2) www.example2.com
(3) www.example3.com


since, we need to configure name based web server , we can create three different directories for apache to fetch the index.html file from three different locations.


sudo mkdir /var/www/example1.com

sudo mkdir /var/www1/example2.com

sudo mkdir /var/www2/example3.com


Now create an index.html file for those three domains inside those three directories by,

sudo gedit /var/www/example1.com/index.html

one file will be opened,and just enter some text in that file

“Knowledge increases only when shared”

and then save the file.

sudo gedit /var/www1/example2.com/index.html

enter some text,

“We are all rewarded not for having brains ,but for using it.”

and then save the file.

sudo gedit /var/www2/example3.com/index.html

enter some text,

“Triumph and Disaster must be treated same”

now,save and exit the file.

Now we have to edit the apache configuration file to make the apache to listen to the newly created index.html files.


sudo gedit /etc/apache2/sites-available/default

NameVirtualHost 192.168.1.16
<VirtualHost www.example1.com>
ServerAdmin webmaster@localhost
ServerName www.example1.com
DocumentRoot /var/www/example1.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/example1.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

</VirtualHost>

<VirtualHost www.example2.com>
ServerAdmin webmaster@localhost
ServerName www.example2.com
DocumentRoot /var/www1/example2.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www1/example2.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost www.example3.com>
ServerAdmin webmaster@localhost
ServerName www.example3.com
DocumentRoot /var/www2/example3.com
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www2/example3.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>


and then save the file.

Note: Make sure to replace the ip address 192.168.1.16 to your own system ip address,which is in the first line of the file.

Now restart the apache service for the changes to take effect.

sudo /etc/init.d/apache2/restart.


now check in browser by giving,

www.example1.com


you should get a page with a content like this,

Knowledge increases only when shared


now try with www.example2.com

you should get like this.

We are all rewarded not for having brains ,but for using it.

try with www.example3.com

you should get like this

Triumph and Disaster must be treated same.

Now your newly configured name based web server should work fine.
Posted in Uncategorized
Views 1366 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 09:34 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration