Use Virtual Hosts from Apache2 with Vagrant

1

I have recently discovered Vagrant, and am using it. It is very functional, I defined an IP, installed apache, php and cia ...

I am accessing the projects by host, via localhost: 8080 or by IP 192.168.33.0

But I want to be able to access the same way I accessed on the local server, via project1.dev, project2.dev, project3.dev, project4.dev ...

How to access projects in Vagrant using Virtual Hosts?

    
asked by anonymous 27.11.2014 / 18:58

1 answer

0

In the windows hosts file 'C: \ Windows \ System32 \ drivers \ etc \' add the IP you configured in the Vagrant file and the domain you want.

In Apache you configure this domain to access the folder of your project.

For example, I'll set up a project and use matheusilario.mi to access it and in apache it would do the following configuration:

  • In the folder / etc / apache2 / sites-avaible create the site file according to the project folder in www: created the folder matheusilario configuration file would be matheusilario.conf
  • The contents of this file:

    ServerName matheusilario.mi ServerAlias www.matheusilario.mi

    DocumentRoot / var / www / html / matheusilario /

        Options FollowSymLinks     AllowOverride All

        Options FollowSymLinks MultiViews     AllowOverride All     Require all granted

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

  • 19.08.2016 / 16:25