Apache Shared Hosting
Apache Shared Hosting
Introduction : -
Shared Hosting or Virtual Hosting refers to a hosting service where more than one web site
reside on the same server , each web site has its own space.
Apache Shared Hosting can be implementing in two ways :-
1- Apache !-based virtual Hosting : - each web site should has its own ! address or web
sites can share one ! address but with different !"#$ number %www.site1.com:&&&& ,
www.site'.com:&&&( ... ) .
'- Apache *ame-based Virtual Hosting :- more than one web site can share the same !
address , that means all web sites in the +*S point to the same ! address and the apache
ta,es care of redirect the re-uester to the correct site.
./ample :-
/ hosting company host si/ web sites % www.site1.com , www.site'.com .... www.site0.com )
on the same server and each of them belong to different person.
Implementation :-
assume we have one server running solaris 11 and we want to host two web sites on this
server .
Information :-
- 2irst web Server ! :- 1('.10&.1.31
- Second web Server ! :- 1('.10&.1.31 %you need the second ! 4ust if you want to
implement !-based Virtual host based on port number)
- first web site name :- site1.com
- second web site name :- site'.com
Steps :-
*ote :- 5lear cache storage in the web browser before test any changes .
- !-based virtual host %case 1 :- each site has its own ! address )
ma,e sure the apache service is running on solaris 11 , at the prompt type :-
svcs -a 6 grep -i apache'
if the apache is running you will see the following : -
online 1:'&:17 svc:8networ,8http:apache'
if the status is disabled ,
disable 1:'&:17 svc:8networ,8http:apache'
enable it , at the command prompt type :-
svcadm enable apache'
create directories that will hold site1 and site ' files ,
cd 8var8apache'8htdocs
m,dir site1 site'
cd site1
echo 9Site1 !age9::inde/.html
cd ..
cd site'
echo 9Site' !age9::inde/.html
note that the 98var8apache'8htdocs is the +ocument#oot folder which holds all web sites files.
5opy the file 8etc8apache'8httpd.conf-e/ample to 8etc8apache'8httpd.conf by running the
following command .
cp 8etc8apache'8httpd.conf-e/ample 8etc8apache'8httpd.conf
edit the httpd.conf file as the following :-
vi 8etc8apache'8httpd.conf
2ollow the lin, to 5onfigure basic apache setting :- 5onfigure Apache on Solaris
scroll down until you reach Virtual Hosts section .
add the following information :-
;VirtualHost 1('.10&.1.31:&1:
Server*ame site1.com
ServerAdmin admin<site1.com
+ocument#oot 8var8apache'8htdocs8site1
.rror=og 8var8apache'8logs8site1.error.log
5ustomlog 8var8apache'8logs8site1.access.log combind
;8VirtualHost:
;VirtualHost 1('.10&.1.33:&1:
Server*ame site'.com
ServerAdmin admin<site'.com
+ocument#oot 8var8apache'8htdocs8site'
.rror=og 8var8apache'8logs8site'.error.log
5ustom=og 8var8aapche'8logs8site'.access.log
;8VirtualHost:
save and close the document.
restart the apache service
svcadm restart apache'
now , you have completed the configuration , try to access the site1.com by its ! address by
type 1('.10&.1.31 in the web browser , if you see Site1 !age then your configuration is "> ,
now try to access site'.com by type 1('.10&.1.33 in the web browser , you have to see Site'
!age.
if you want to access site1 and site' by names add a recored in the +*S for site1 and site' ,
if you don?t have a +*S server you can do that from hosts file in the operating system as
follow :-
@*A B =inu/ C edit 8etc8hosts file and add a record for site1 and site' as following :-
1('.10&.1.31 site1.com
1('.10&.1.33 site'.com
Dindows C edit 5:ED*+"DSEsystem7'EdriversEetcEhosts file and add a record for site1
and site as following :-
1('.10&.1.31 site1.com
1('.10&.1.33 site'.com
-!-based virtual host % case ' :- web sites share one ! address with different !"#$ )
clear all configuration in previous step .
ma,e sure the apache service is running on solaris 11 , at the prompt type :-
svcs -a 6 grep -i apache'
if the apache is running you will see the following : -
online 1:'&:17 svc:8networ,8http:apache'
if the status is disabled ,
disable 1:'&:17 svc:8networ,8http:apache'
enable it , at the command prompt type :-
svcadm enable apache'
create directories that will hold site1 and site ' files .
cd 8var8apache'8htdocs
m,dir site1 site'
cd site1
echo 9Site1 !age9::inde/.html
cd ..
cd site'
echo 9Site' !age9::inde/.html
note that the 98var8apache'8htdocs is the +ocument#oot folder witch holds all web sites files .
5opy the file 8etc8apache'8httpd.conf-e/ample to 8etc8apache'8httpd.conf by running the
following command .
cp 8etc8apache'8httpd.conf-e/ample 8etc8apache'8httpd.conf
edit the httpd.conf file as the following :-
vi 8etc8apache'8httpd.conf
scroll down until you reach =isten +irective , add the following information :-
=isten 1('.10&.1.31:&1&1
=isten 1('.10&.1.31:&1&'
scroll down until you reach Virtual Host section and ad the following :-
;VirtualHost 1('.10&.1.31:&1&1:
Server*ame site1.com
ServerAdmin admin<site1.com
+ocument#oot 8var8apache'8htdocs8site1
.rror=og 8var8apache'8logs8site1.error.log
5ustomlog 8var8apache'8logs8site1.access.log combind
;8VirtualHost:
;VirtualHost 1('.10&.1.31:&1&1:
Server*ame site'.com
ServerAdmin admin<site'.com
+ocument#oot 8var8apache'8htdocs8site'
.rror=og 8var8apache'8logs8site'.error.log
5ustom=og 8var8aapche'8logs8site'.access.log
;8VirtualHost:
save and close the document.
restart the apache service
svcadm restart apache'
now , you have completed the configuration , try to access the site1.com by its ! address by
type 1('.10&.1.31:&1&1 in the web browser , if you see Site1 !age then your configuration is
"> .
now try to access site'.com by type 1('.10&.1.31:&1&1 in the web browser you have to see
Site' !age.
if you want to access site1 and site' by names add a recored in the +*S for site1 and site' ,
if you don?t have a +*S server you can do that from hosts file in the operating system as
follow :-
@*A B =inu/ C edit 8etc8hosts file and add a record for site1 and site' as following :-
1('.10&.1.31 site1.com
1('.10&.1.31 site'.com
Dindows C edit 5:ED*+"DSEsystem7'EdriversEetcEhosts file and add a record for site1
and site as following :-
1('.10&.1.31 site1.com
1('.10&.1.31 site'.com
in the browser type site1.com:&1&1 and site'.com:&1&1
- *ame-Fased Virtual Host
clear all configuration in previous step .
ma,e sure the apache service is running on solaris 11 , at the prompt type :-
svcs -a 6 grep -i apache'
if the apache is running you will see the following : -
online 1:'&:17 svc:8networ,8http:apache'
5opy the file 8etc8apache'8httpd.conf-e/ample to 8etc8apache'8httpd.conf by running the
following command .
cp 8etc8apache'8httpd.conf-e/ample 8etc8apache'8httpd.conf
create directories that will hold site1 and site ' files .
cd 8var8apache'8htdocs
m,dir site1 site'
cd site1
echo 9Site1 !age9::inde/.html
cd ..
cd site'
echo 9Site' !age9::inde/.html
edit the httpd.conf file as the following :-
vi 8etc8apache'8httpd.conf
scroll down until you reach Virtual Host section and ad the following :- *ameVirtualHost
1('.10&.1.31:&1
;VirtualHost 1('.10&.1.31:
Server*ame site1.com
ServerAdmin admin<site1.com
+ocument#oot 8var8apache'8htdocs8site1
.rror=og 8var8apache'8logs8site1.error.log
5ustomlog 8var8apache'8logs8site1.access.log combind
;8VirtualHost:
;VirtualHost 1('.10&.1.31:
Server*ame site'.com
ServerAdmin admin<site'.com
+ocument#oot 8var8apache'8htdocs8site'
.rror=og 8var8apache'8logs8site'.error.log
5ustom=og 8var8aapche'8logs8site'.access.log
;8VirtualHost:
save and close the document.
restart the apache service
svcadm restart apache'
if you want to access site1 and site' by names add a recored in the +*S for site1 and site' ,
if you don?t have a +*S server you can do that from hosts file in the operating system as
follow :-
@*A B =inu/ C edit 8etc8hosts file and add a record for site1 and site' as following :-
1('.10&.1.31 site1.com
1('.10&.1.31 site'.com
Dindows C edit 5:ED*+"DSEsystem7'EdriversEetcEhosts file and add a record for site1
and site as following :-
1('.10&.1.31 site1.com
1('.10&.1.31 site'.com
in the browser type site1.com and site'.com