Skip to content

Instantly share code, notes, and snippets.

@lozadaOmr
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save lozadaOmr/15e1d72ee284b988830f to your computer and use it in GitHub Desktop.

Select an option

Save lozadaOmr/15e1d72ee284b988830f to your computer and use it in GitHub Desktop.

TODO

Check if apache vhost_alias, rewrite** module is enabled

sudo a2enmod vhost_alias

sudo a2enmod rewrite

restart/reload apache server when prompted

**REWRITE module is needed on Laravel projects

Create an entry in the HOSTS file

sudo nano /etc/hosts

On the hosts file, create this record

127.0.0.1    test.dev

The syntax is as follows the IP ADDRESS followed by the ServerName on the above example I created it as test.dev, therefore you can access the server on the browser by typing test.dev

Create a VHOST

cd /etc/apache2/sites-available/
touch test.dev.conf
nano test.dev.conf

touch test.dev.conf - this will create a .conf file or configuration for the vhost test.dev The syntax is [ServerName].conf , if we created on /etc/hosts a 127.0.0.1 practice.com then our conf file will be practice.com.conf

test.dev.conf

<VirtualHost *:80>
    DocumentRoot /var/www/test.dev
    ServerName test.dev
</VirtualHost>

This is the bare syntax when creating VHOST *:80 tells that it will listen to any IP on port 80 DocumentRoot where the root directory for the VHOST ServerName - the name we will access locally, also must be the same in /etc/hosts

Enable VHOST

sudo a2ensite test.dev.conf

a2ensite [ServerName].conf

Disable VHOST

sudo a2dissite test.dev.conf

After enabling your VHOST you can now try and access your server on the browser by typing test.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment