Creating virtual host is solution if you have multiple website running on one web server, even if your web server is on local computer not online at all. In this article i will show you how to create virtual host for apache web server on lubuntu.
Alright, for this tutorial we are going to create a new virtual host and we are going to name it lubuntu.howto, so when open http://lubuntu.howto/ it will shows it's own web page, it will be different with the http://localhost/ or any other local domain.
Alright, for this tutorial we are going to create a new virtual host and we are going to name it lubuntu.howto, so when open http://lubuntu.howto/ it will shows it's own web page, it will be different with the http://localhost/ or any other local domain.
Step by step how to create virtual host on apache web server
- Install apache web server, read here for more info (skip if you already did this)
- Enable apache mod rewrite, read here for more info (skip if you already did this)
- Create new folder for the virtual host, let's say the folder name is my_lubuntu, since apache2 default document root is on /var/www/html/ so create the new folder on that path, it will be /var/www/html/my_lubuntu/
sudo mkdir /var/www/html/my_lubuntu
- Create a new web page on /var/www/html/my_lubuntu/ called index.html
sudo leafpad /var/www/html/my_lubuntu/index.html
index.html
<html>
<head>
<title>lubuntu</title>
</head>
<body>
<h1>Welcome to lubuntu.howto</h1>
<marquee>This is your new virtual host</marquee>
<marquee>put your web page inside /var/www/html/my_lubuntu/</marquee>
<marquee>It will be available through local domain http://lubuntu.howto/</marquee>
<a href="http://lubuntuhowto.blogspot.com/">dont forget to visit lubuntuhowto.blogspot.com</a>
</body>
</html>
sudo leafpad /etc/apache2/sites-available/lubuntu.howto.conf
lubuntu.howto.conf
<VirtualHost *:80>
ServerName lubuntu.howto
DocumentRoot /var/www/html/my_lubuntu/
<Directory /var/www/html/my_lubuntu/>
AllowOverride all
</Directory>
</VirtualHost>
sudo a2ensite lubuntu.howto.conf
sudo service apache2 restart
sudo leafpad /etc/hosts
127.0.0.1 lubuntu.howto
- Open your favorite web browser and go to address http://lubuntu.howto/
That's it guys, that's how you create a virtual host on apache web server, very easy isn't it? you can create as many virtual host as you like, have fun !
NOTE: leafpad is default text editor on lubuntu, so if you are trying this tutorial using ubuntu, change leafpad into gedit.
This comment has been removed by a blog administrator.
ReplyDelete