In KUbuntu i wanted to make virtual host localhost.example.com working on my local machine what it worked like on Windows 7 earlier. I am posting the complete process here to help someone newbie like me in using KUbuntu operating system on my local machine.
For someone trying to get Named virtual hosts working on Ubuntu i assume that the apache web server is already installed and running.
Here’s the complete process:
As a first step you need to create a new configuration file for your new virtual host. To do this go to:
$ cd /etc/apache2/sites-available
and create a new configuration file by copying the default configuration file, by running
$ sudo cp default rfdf.org
you may need to change the name rfdf.org to suit your setup. After having created new file rfdf.org open this file in edit mode. I would use gedit editor to do so by running the following command.
$ sudo gedit rfdf.org
Once opened edit this file to match your needs. My rfdf.org file would look as under after editing:
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerAlias localhost.rfdf.org DocumentRoot /var/www/rfdf.org <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/rfdf.org> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
Highlighted lines above containing ServerAlias, DocumentRoot and Directory parameters are important. Once changes made save and close this file. Now we have made the configuration for new virtual host “available” and we need to make it “enabled”, next.
To enable the new virtual host configuration do any of the following, depending of your system settings.
Either do
$ sudo a2ensite rfdf.org
or
Go to sites-enabled folder by doing
$ cd /etc/apache2/sites-enabled/
$ sudo ln -s /etc/apache2/sites-available/rfdf.org rfdf.org
Both of them would enable the new virtual host.
Now, as a last step tell your apache server to look for localhost.rfdf.org in your local maching and not over the internet, by editing your hosts file:
$ sudo gedit /etc/hosts
and adding a new line (as under) at the bottom:
127.0.0.1 localhost.rfdf.org www.localhost.rfdf.org
Reload the apache by running:
sudo /etc/init.d/apache2 reload
and open the http://localhost.rfdf.org in your web browser. It should work.
Thank you dude! It was so nicely explained. Following this post it took me just two minutes to set up a new virtual host on Ubuntu. Nice job!