After a long time, I get back to my blog. For last few days I was too busy for some LAMP projects. Hopefully now on, I will be available in my blog with new spicy topics.
Configuring a virtual host is really important if anybody works as web developer. It will give your separate hosting environment by keeping specific features from another one. Beside this, I have a plan to write a complete tutorial on setting up LAMP environment with proper extension for being a professional developer. Though it’s not so difficult, but sometimes it turns you in some troubles. However, let me explain it by following some easy steps . . .
Assuming that apache2 is already installed in your PC. if it is not, please follow this tutorial: https://help.ubuntu.com/6.06/ubuntu/serverguide/C/httpd.html. Whatever, first thing is to create configuration file in /etc/apache2/sites-available by gedit, nano or any other text editor. Suppose, the configuration file name is eftakhairulweb.com and local IP address is 127.0.0.1. Type following command in terminal….
gksudo gedit /etc/apache2/sites-available/eftakhairulweb.com
Add following lines in configuration file
<VirtualHost 127.0.0.1:80> DocumentRoot /var/www/eftakhairulweb.com ServerName eftakhairulweb.com ServerAlias www.eftakhairulweb.com ServerAdmin [email protected] </VirtualHost>
Save and close it. Now create a symbolic link of this configuration file to /etc/apache2/sites-enabled directory in order to enable it
cd /etc/apache2/sites-enabled/ sudo ln -s ../sites-available/eftakhairulweb.com .
Now, add a virtual domain with a specific local IP to hosts file that is located in /etc/hosts. You can also add the port using a colon with the IP.
sudo nano /etc/hosts
add this line
Save and close it. Almost done. Finally, restart the apache service.
sudo /etc/init.d/apache2 restart
Done. Keep it in your mind that you can make multiple name based virtual hosts based on your IP address. Best practice is make separate configuration for each virtual host.