How can I set up a VirtualHost on my local developer environment? Ideally I would also like to be able to access my site from a simply URL, such as www.joomla.loc rather than having to constantly use the localhost URL.
In this I will explain how to set this up for Wampserver 2.5 with Apache 2.4+.
Once you have downloaded, installed and started Wampserver, go to the following directory on your computer and created a new folder called "joomla"
Within your newly created folder, extract the Joomla zip file.
Now that you have your new folder with the Joomla installation in there, you now need to open the following file in a text editor, such as Notepadd++
In this file, add the following, which will map the localhost IP address to the defined URL:
127.0.0.1 joomla.loc www.joomla.loc
Note that I have 2 instances, 1 with
www and 1 without. If you are unable to save and are thrown a permissions error, try running your text editor on Administrator Mode, by right clicking the .exe and going to "Run as Administrator".
Save the file, and then open the following file in your text editor
Add the following to the file above at the bottom:
<VirtualHost *:80> DocumentRoot "C:/wamp/www/joomla" ServerName joomla.loc <Directory "C:/wamp/www/joomla"> AllowOverride All Require local </Directory> </VirtualHost>
The above code is only for Apache 2.4+ and will NOT work for Apache 2.2.
You've now created your VirtualHost for your newly created folder. All you need to do now is restart Apache, by clicking the green Wampserver on your taskbar, then clicking "Restart All Services" as shown in the screenshot below:
You can now type in
www.joomla.loc in your browser and install Joomla
Hope this helps. Would be also nice if some people who are running other development environments such as Xampp, Lamp and Mamp could post an answer too
Instructions for Linux OS with Apache 2+ Server:
Edit the file
/etc/hostsand add this line:
/etc/apache2/sites-enableddirectory, then open it and add these lines:
<VirtualHost *:80> ServerName joomla DocumentRoot /var/www/joomla <Directory /var/www/joomla> AllowOverride All </Directory> </VirtualHost>
Restart the Apache server:
sudo /etc/init.d/apache2 restart
Now type in your browser's address bar:
http://joomla and hit Enter!
- You must be a super user in order to edit the above files.
If you use Geany text editor, the command would be:
sudo geany /etc/hosts
sudo geany /etc/apache2/sites-enabled/joomla.conf
I've just did this with OSX and here's how;
All websites on OSX are stored in
Create a new website folder called 'joomla'
cd ~/Sites/ mkdir joomla
Now add a new record to Apache's host file - edit
httpd-vhosts.conf file normally located in
Add the following to the file (change names accordingly);
<VirtualHost *:80> DocumentRoot "/Users/UserName/Sites/joomla" ServerName joomla <directory "/Users/UserName/Sites/joomla"> AllowOverride All </directory> </VirtualHost>
ServerName is the name you will type into your address bar to access your website.
DocumentRoot is where your website is located.
Now edit the
hosts file normally located in
Add another record to point to the new website;
Lastly, restart Apache
You should now be able to go to
http://joomla and acces your website!
Worked for me.
Hopefully I haven't left anything out!