Skip to content

Instantly share code, notes, and snippets.

@gaintsev
Created August 28, 2018 15:50
Show Gist options
  • Save gaintsev/7406435fb83831335acf2f01be6db05a to your computer and use it in GitHub Desktop.
Save gaintsev/7406435fb83831335acf2f01be6db05a to your computer and use it in GitHub Desktop.
Multiple sites on Vagrant virtual machine
  1. On the guest machine add all sites to /etc/apache2/sites-available/000-default.conf. Example:
<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/foo

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ServerName foo.localhost

</VirtualHost>

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/bar

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ServerName bar.localhost

</VirtualHost>
  1. Restart apache sudo systemctl reload apache2

  2. On the host machine edit your /etc/hosts file:

192.168.33.10 foo.localhost
192.168.33.10 bar.localhost

See IP from your Vagrant config (Vagrantfile)

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