Friday, June 5, 2015

Apache2: Configuring a local page with custom host name (Virtual Host)

1. Create a folder /wwww/domain
sudo mkdir -p /www/domain 

2. Change permissions
sudo chown 755 /www/domain sudo chown -R www-data:www-data /www/domain 

3. Edit Apache2 conf
sudo gedit /etc/apache2/apache2.conf Add these lines:
<VirtualHost *:80>
    # This first-listed virtual host is also the default for *:80
    ServerName gabo.com
    ServerAlias gabo.com
    DocumentRoot /www/domain
</VirtualHost>

<Directory /www/domain/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

4. Add DNS line in /etc/hosts
127.0.0.1 gabo.com 

 5. Create index file
touch /wwww/domain/index.html add HTML code:
<http>
<body>
<h1>Hello!</h1>
</body>
</http>

6. Open domain gabo.com in browser.

No comments:

Post a Comment