Adding New VirtualHost in Apache2

Written by

in

, ,

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:


ServerName dev.newwebsite.com
DocumentRoot "/var/www/www.newwebsite.com"

# Error handlers
ErrorDocument 500 /errordocs/500.html


AllowOverride All
Options -Indexes FollowSymLinks
Allow from all


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

3. Restart your apache

$ /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

Comments

Leave a Reply

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