30th Jul2012
Author: Gyro

Setup Virtual Hosts using Apache2 on Ubuntu 12.04

When I started programming website on a localhost, I often ran into issues setting up SEF URLs. So, I started using virtual hosts by creating fake domain names and then make them connect to the local apache server via the hosts file.

For example, if I work on webdesignblog.asia on my localhost, I am accessing webdesignblog.dev, which is a fake domain linked to my localhost via the virtual hosts (enabled sites) and hosts modifications.


Here are the steps needed to setup your own virtual host:

Create a configuration file for the virtual host / domain:
# sudo nano /etc/apache2/sites-available/webdesignblog.dev
Modify the text block below and then paste it in the file

# Place any notes or comments you have here
# It will make any customisation easier to understand in the weeks to come

# domain: webdesignblog.dev
# public: /home/wdb/public_html/

<VirtualHost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin [email protected]
ServerName webdesignblog.dev
ServerAlias www.webdesignblog.dev

# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /home/wdb/public_html/

# Custom log file locations
LogLevel warn
ErrorLog /home/demo/public_html/domain1.com/log/error.log
CustomLog /home/demo/public_html/domain1.com/log/access.log combined
</VirtualHost>


# sudo a2ensite webdesignblog.dev
# sudo service apache2 reload

3192

Keep Me Going
Your Name / Website:
Did you like my post? Buy me a Bitcoffee! 14JX52Li7zTKbyQv2omw4tvu6Bi1KzfHNW



One Response to “Setup Virtual Hosts using Apache2 on Ubuntu 12.04”

Leave a Reply

Your email address will not be published. Required fields are marked *

What is 13 + 9 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)