Adding New VirtualHost in Apache2

On linux Ubuntu
1. If your apache has /etc/apache2/sites-available directory then just create a new file “dev.newwebsite.com.conf”
with the following content:

1
2
3
4
5
6
7
8
9
10
11
12
13
<VirtualHost *:80>
    ServerName dev.newwebsite.com
    DocumentRoot "/var/www/www.newwebsite.com"

    # Error handlers
    ErrorDocument 500 /errordocs/500.html

    <Directory "/var/www/www.newwebsite.com">
        AllowOverride All
        Options -Indexes FollowSymLinks
        Allow from all
    </Directory>   
</VirtualHost>

2. Also copy the same file into /etc/apache2/sites-enabled

3. Restart your apache

1
$ /etc/init.d/apach2 restart

4. Edit your hosts file: /etc/hosts
add the following line to it
127.0.0.1 dev.newwebsite.com

5. Open your web browser and open http://dev.newwebsite.com

If you are a windows user and are using xampp then you need to alter the vhost configuration file.
The default xampp file is in
“\xampp\apache\conf\extra\httpd-vhosts”
Then restart your apache

This entry was posted in Operating System, php, Ubuntu. Bookmark the permalink.

Leave a Reply

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


seven × = 7