1.
sudo nano /etc/apache2/sites-available/obeikan
Type the code bellow in this file:
2. sudo nano /etc/hosts
ServerName obeikan.com
ServerAlias www.obeikan.com
DocumentRoot /home/barek/projects/obeikan
CustomLog /var/log/apache2/obeikan.log comboned
Type the code in this file:
127.0.0.1 localhost
127.0.0.1 test_site www.test_site.com
127.0.0.1 obeikan www.obeikan.com
127.0.1.1 barek-ubuntu
3.
sudo a2ensite obeikan
#sudo a2dissite obeikan (this command is used for disabling site)
4.
sudo /etc/init.d/apache2 reload #restart apache
5.
sudo gedit /etc/apache2/httpd.conf #edit for once if this file is blank and apache2 gives warning(this is optional)
ServerName localhost
Now type www.obeikan.com on your browser and booooooooom!!
For Advanced Virtual host configuration follow these:
ServerName test_site.com
ServerAlias www.test_site.com
DocumentRoot /var/www/test_site
CustomLog /var/log/apache2/test_site.log comboned
Deny from all
Allow from 192.168.1.2 127.0.0.1
AuthType Basic
AuthName "Private Documentation Repository"
AuthUserFile /var/www/.htpasswd-private
Require valid-user