Saturday, 10 August 2013

HOW TO CONFIGURE WEBSERVER IN LINUX

Configure web server

In this example we will configure a web server.
necessary rpm for web server is httpd, httpd-devel and apr check them for install
rpmNow configure the ip address to 192.168.0.254 and check it
ifconfig
start httpd daemons and verify its running status
pgrep httpd

Configure virtual hosting

In this example we will host a website www.vinita.com to apache web server. create a documents root directory for this website and a index page
mkdir vinita
for testing purpose we are writing site name in its index page
index.htm
save file and exit
now open /etc/hosts file
hosts
in the end of file bind system ip with www.vinita.com
entry of vinita in hosts
now open /etc/httpd/conf/httpd.conf main configuration file of apache server
vi httpd.conf
locate virtual host tag
virtual host
remove # from the beginning and add the IP of host
virtual host
Now go in the end of file and copy last seven line [ virtual host tag ] and paste them in the end of file. change these seven lines as shown in image
httpd.conf
now save this file and exit from it
you have done necessary configuration now restart the httpd service and test this configuration run links command
links
if links command retrieve your home page

means you have successfully configured the virtual host now test it with site name
links vinita
In output of links command you should see the index page of site
webpage of vinita

Configure multiple site with same ip address

At this point you have configured one site www.vinita.com with the ip address 192.168.0.254. Now we will configure one more site www.nikita.com with same ip address
create a documents root directory for www.nikita.com website and a index page
create virtual directory
for testing purpose we are writing site name in its index page
index.htm
save file and exit
now open /etc/hosts file and bind system ip with www.nikita.com
hosts
now open /etc/httpd/conf/httpd.conf main configuration file of apache server
vi httpd.conf
Now go in the end of file and copy last seven line [ virtual host tag ] and paste them in the end of file. change these seven lines as shown in image
httd.conf
now save this file and exit from it
you have done necessary configuration now restart the httpd service
service httpd restart
test this configuration run links command
links
In output of links command you should see the index page of site

configure multiple site with multiple ip address

Now we will host multiple sites with multiple ip address. Create a virtual lan card on server and assign its an ip address of 192.168.0.253. we will create a testing site www.nidhi.com and will bind it with ip address of 192.168.0.253
create a documents root directory for www.nidhi.com website and a index page
vi nidhi
for testing purpose we are writing site name in its index page
index.htm
save file and exit
now open /etc/hosts file and bind system ip with www.nidhi.com
hosts
now open /etc/httpd/conf/httpd.conf main configuration file of apache server
vi httpd.conf
Now go in the end of file and copy last seven line [ virtual host tag ] and paste them in the end of file. change these seven lines as shown in image
httpd.conf
now save this file and exit from it
you have done necessary configuration now restart the httpd service
service httpd restart
test this configuration run links command
links
In output of links command you should see the index page of site

How to create site alias

Now I will show you that how can you use site alias to configure more name of same site. we configure a site www.vinita.com in stating of example. now we will create www.goswami.com site alias for this site so this site can be access with both name.
To create alias first make its entry in /etc/hosts file as shown here
hosts
Now open main apache configuration /etc/httpd/conf/httpd.conf
vi httpd.conf
Now go in the end of file and copy last seven line [ virtual host tag ] and paste them in the end of file. change these seven lines as shown in image
httpd.conf
now save this file and exit from it
you have done necessary configuration now restart the httpd service and test this configuration run links command
links
In output of links command you should see the index page of site
webpage of goswami

No comments:

Post a Comment