Configure Apache2 VirtualHost in Ubuntu
What is Apache2 VirtualHost?
Apache2 VirtualHost is use for multidomain purpose. We need to configure 2 VirtualHost name to each domain, so we can see a different website from each domain.
First I assume we have installed apache2 webserver and it's running smootly in Ubuntu Server.
To configure apache webserver VirtualHost in Ubuntu server is different from other linux OS like fedora/redhat/centos. In Ubuntu apache2 have separated the virtual host into sites-available and sited-enabled directory.
Example we have domain inferno.web.id
We need to login into the server and have a root user previleges.
We also need to create a file name inferno.web.id in sites-available directory
[code]sentono@athena:~$sudo su
Password:
root@athena:/home/sentono#[/code]
Change directory to /etc/apache2/sites-available/
[code]root@athena:/home/sentono#cd /etc/apache2/sites-available/
root@athena:/etc/apache2/sites-available#[/code]
Add NameVirtualHost into Default site
[code]root@athena:/etc/apache2/sites-available#pico default[/code]
#change or add this line below
[code]NameVirtualHost 192.168.1.1:80[/code]
#save and exit
Create a new virtualhost file
[code]root@athena:/etc/apache2/sites-available#pico inferno.web.id
<VirtualHost 192.168.1.1:80>
ServerName inferno.web.id
DocumentRoot /home/www/inferno.web.id/public_html/
</VirtualHost>
#save this file and exit [/code]
We need to enabled our new Website
[code]root@athena:/etc/apache2/sites-available#a2ensite inferno.web.id[/code]
Restart Apache2 Webserver
[code]root@athena:/etc/apache2/sites-available#/etc/init.d/apache2 restart[/code]
Create testing index.php
[code]root@athena:/etc/apache2/sites-available#nano /home/www/inferno.web.id/public_html/index.php
<? phpinfo() ?>
#save and exit[/code]
Testing it with IE
[code]http://inferno.web.id[/code]
Recent blog posts
|
Recent comments
|
Comments
Thank you for this tutorial
This tutorial really help my problems. thank you very much.
thanks for your tutorial my
thanks for your tutorial
my ques. is what's "192.168.1.1" ip refers to ? internal,external of the server..
thanks again
192.168.1.1 ip refers to your
192.168.1.1 ip refers to your external ip address.
This is also could be your internal ip address if you are using NAT to your external ip server.
FYI : 192.168.1.1 is just a example ip address so if you want to put the ip address there, you should put your external ip address there
Other tutorials
I also liked these two tutorials on setting up virtual hosts on Ubuntu:
http://www.techmongrel.com/05/setting-up-a-virtual-host-using-apache-2-o...
http://www.debianhelp.co.uk/virtualhosts.htm
Post new comment