Apache is the most widely used Web Server application in the world with more than 50% share in the commercial web server market. Virtual hosting is one such feature that allows a single Apache Web Server to serve a number of different websites. The word, Apache, has been taken from the name of the Native American tribe ‘Apache’, famous for its skills in warfare and strategy making.
Installing apache from the source require the –devel package to be installed on your server. You can find the latest available version of Apache, you can download it here:
http://httpd.apache.org/download.cgi .
Once you download the source file move it to the /usr/local/src folder.
[root@haktuts ~] cd /usr/local/src
>Go to /usr/local/src directory
[root@haktuts ~] gzip -d httpd-2.2.26.tar.gz
>Apache file is archived with .tar.gz so first use gzip command to extract the data from gzip.
[root@ haktuts ~] tar xvf httpd-2.2.26.tar
>Now use tar command to extract the data from .tar archived file.
[root@ haktuts ~] httpd-2.2.26
[root@ haktuts ~] ./configure –help
>see all configuration option
[root@ haktuts ~] ./configure –prefix=/usr/local/apache –enable-so
>The compilation of Apache within the /usr/local/apache directory with the DSO capability. The –enable-so option, can load required modules to apache at run time via the DSO mechanism rather than requiring a recompilation.
[root@ haktuts ~] make
[root@ haktuts ~] make install
>use to make the file and install
[root@ haktuts ~] iptables -I INPUT -p tcp --dport 80 -j ACCEPT
>command to open port 80 in firewell
There are two types of virtual hosts supported by Apache –
1.Name-based virtual host
2.Address-based or IP based virtual host
1.Name-based Virtual Host
Name based virtual hosting is used to host multiple websites on a single IP address.for this user have to edit the httpd.conf file & copy the colored content below and paste it.
NameVirtualHost *:80
<VirtualHost 192.168.0.108:80>
ServerAdmin hak@haktuts.com
DocumentRoot /var/www/html/haktuts.com
ServerName www.haktuts.com
</VirtualHost>
<VirtualHost 192.168.0.108:80>
ServerAdmin tuts@haktuts.in
DocumentRoot /var/www/html/haktuts.in
ServerName www.haktuts.in
</VirtualHost>
Now check the configuration file and make sure all “syntax Ok” with below command
[root@haktuts ~]httpd –t
2.IP-based Virtual host
Listen 192.168.0.10:80
<VirtualHost 192.168.10.18:80>
ServerAdmin hak@haktuts.com
DocumentRoot /var/www/html/ haktuts.com
ServerName www. haktuts.com
</VirtualHost>
<VirtualHost 192.168.10.19:80>
ServerAdmin tuts@ haktuts.in
DocumentRoot /var/www/html/ haktuts.in
ServerName www.haktuts.in
</VirtualHost>
In ip based hosting, multiple ip address is used as shown above for configuration
If user want to deploy the php website then mod_php enabled on your server
This file is find in /etc/httpd/conf.d/ directory.
Check the mod_php with following command
httpd -M | grep "php5_module"
| means pipe and show the details in table views i.e.in more format
grep is like finding the particular word in whole directory here we are looking for php5_module so command will be grep "php5_module"
© 2014 HaKTuts. All rights reserved.