Using Apache2 Virtual Hosts with Vagrant

Asked

Viewed 199 times

1

I discovered Vagrant recently, and am using it. It is well functional, set an IP, installed apache, php and cia...

I’m accessing the projects via the host, via localhost:8080 or IP 192.168.33.0

But I want to be able to access it the same way I did on the local server, via project 1.dev, project2.dev, project3.dev, project4.dev...

How to access projects in Vagrant using Virtual Hosts?

1 answer

0

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

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

For example, I will configure a project and use matheusilario.mi to access it and in apache I would do the following configuration:

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

    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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.