Skip to content

Instantly share code, notes, and snippets.

@rmatil
Last active August 29, 2015 14:15
Show Gist options
  • Save rmatil/787b424f9bd2098dc794 to your computer and use it in GitHub Desktop.
Save rmatil/787b424f9bd2098dc794 to your computer and use it in GitHub Desktop.
Setup Vagrant for local development with PHP and multiple Vhosts

Generate Vagrantfile

Visit https://puphpet.com/ and build the local development environment. Download the generated Vagrantfile and the corresponding puphet directory and move it to your Document Root.

Note: Use web folder for Document Root on projects which provide it.

Set up local environment

  • Install vagrant and VirtualBox.
  • Run vagrant up in the Document Root of the server

Check Settings in VHosts

  • Run vagrant ssh to ssh into the local develompent machine
  • Navigate to /etc/apache2/sites-enabled/
  • Check for each enabled vhost if mod_rewrite is enabled
  • In case it is, there should be a paragraph which looks like the following:

    ## Directories, there should at least be a declaration for /var/www/project.dev.localhost/web
    <Directory "/var/www/project.dev.localhost/web">
        Options Indexes FollowSymlinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

Note: At time of writing, there existed an issue, which caused vagrant/chef/puppet (or whatever) to not create the <Directory ... entry for all vhosts but the first. So we have to manually add them. After updating the vhosts file restart apache2 by running sudo service apache2 reload

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