Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Homestead with Apache server

Last year, after being a long time user of a WAMP stack, I switched over to Homestead on Vagrant. For a non-Laravel development project, I am required to use Apache Server. I know that it is possible to install Apache server on Homestead and then add Virtual Hosts for each site, but this seems a bit impractical. The sites in the Homestead.yaml file work with Nginx but don't seem to work with Apache.

My questions are:

  • Is there away of creating the Virtual Hosts automatically in Apache?
  • Is there another Vagrant box that would do this or that you can recommend for use with Apache?
  • Am I just missing something?

I'm kind of a noob in these things. Any help is greatly appreciated!

like image 761
Wouter C Avatar asked Feb 01 '17 09:02

Wouter C


2 Answers

As for now, to make a site entry in Homestead.yaml file works with Apache2, you need to:

1- Add the site to Homestead.yaml, with type: apache as fellow

sites:
    -
        map: homestead.test
        to: /home/vagrant/code/Laravel/public    
    -
        map: homestead.test
        to: /home/vagrant/code/Apache/public
        type: apache

2- go to the vagrant box directory, and run

vagrant destroy

3- then run

vagrant up

4- shh to the vagrant machine

vagrant ssh

5- flip the server, by running:

flip

you'll get this message:

nginx stopped
apache started

To test

I've created the directory Apache/public

mkdir -p Apache/public

then inside it, I've created the file index.php

echo "<?php phpinfo();" > Apache/public/index.php

Which is accessible using the same IP address of the default homestead negix site

like image 148
yaitloutou Avatar answered Nov 16 '22 02:11

yaitloutou


Add type: apache to your homestead.yaml sites configuration, then realod the vagrant machine using vagrant reload --provision

sites:
    - map: homestead.test
      to: /home/vagrant/code/{path/to/laravel}/public
      type: "apache"

Learn more in laravel doc

like image 20
jking Avatar answered Nov 16 '22 02:11

jking