MacOS Sierra 10.12.4
ip: "192.168.50.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys: [ ~/.ssh/id_rsa ]
folders:
- map: ~/Projects/Playground/phpinfo
to: /home/vagrant/phpinfo
- map: ~/Projects/Playground/hello
to: /home/vagrant/hello
sites:
- map: phpinfo.app
to: /home/vagrant/phpinfo/
# type: apache
- map: hello.app
to: /home/vagrant/hello/
type: apache
databases:
- homestead
variables:
- key: APP_ENV
value: local
https://gist.github.com/zela/531b3fb6ef41a33e68fa2fab42c06bb3
http://phpinfo.app shows phpinfo page
http://hello.app shows hello message
Both http://phpinfo.app and http://hello.app show hello message
So Apache servers its site for both URLs
Reload vagrant
http://phpinfo.app shows phpinfo page
http://hello.app shows hello message
Both http://phpinfo.app and http://hello.app show phpinfo
Now nginx serves its site for both URLs!
vagrant up form Homestead directoryvagrant reload form Homestead directorySo it鈥檚聽expectable, that since nginx is primary server for Homestead, it should proxy requests to Apache server for websites wich have type: apache and serve other types of websites normally.
This appears to be intended behavior. Homestead defaults to nginx when there is no site type by creating an nginx virtual host, not proxy to apache. They should both be served by apache when you uncomment the type from phpinfo.app
You will likely run into issues if you're trying to run apache AND nginx hosts on the same Homestead. I would recommend you use the per project install method OR use 1 Homestead for all of your apache projects, and one for all of your nginx projects.
Ok. So probably fix should be in documentation, to declare this incompatibility explicitly.
I was surprised by described behaviour since in some cases it's pretty viable solution to hide apache behind nginx, and supposed that it's supported in Homestead.
Thank you for blazing-fast answer!
We probably should have something in the types docs that mentions no type == nginx. The use case for Apache in Homestead is to use it as the primary server VS behind nginx. Because we're defaulting both vhosts to 80 mixing and matching is what would likely create conflicts.
@zela not sure if you are aware of the flip command that was added a month or two ago. You cannot run Apache and Nginx at the same time, so flip will turn off whichever one is active, and activate the other. I successfully run both Apache and Nginx sites on the same Homestead machine all the time, just have to remember to activate the appropriate web server for whichever site you are currently working on.
@browner12, thank you for the tip!
Note for future users:
I've found also that variables defined in Homestead.yaml don't work with Apache websites.
homestead.rb script adds them to ~/.profile and to /etc/php/7.1/fpm/php-fpm.conf.
PHP-FPM isn't enabled by default in Apache. Enabling it doesn't add environment variables. Looks like in this case it doesn't use config file mentioned above.
Also, websites aren't accessible via https under Apache. Because mod_ssl isn't loaded.
I'd suggest to enable this stuff by default:
sudo a2enmod proxy_fcgi setenvif
sudo a2enconf php7.1-fpm
sudo a2enmod ssl
sudo a2enmod proxy
sudo a2enmod rewrite
The most basic Homestead.yaml that works for testing:
ip: "192.168.50.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys: [ ~/.ssh/id_rsa ]
folders:
- map: ~/Projects/Playground/phpinfo
to: /home/vagrant/phpinfo
sites:
- map: phpinfo-nginx.app
to: /home/vagrant/phpinfo/
- map: phpinfo-apache.app
to: /home/vagrant/phpinfo/
type: apache
variables:
- key: APP_ENV
value: dev
Most helpful comment
Also, websites aren't accessible via https under Apache. Because mod_ssl isn't loaded.
I'd suggest to enable this stuff by default:
The most basic
Homestead.yamlthat works for testing: