Vagrant/Virtualbox Nginx Provisioning - laravel-4

I'm running Laravel/Homestead as my Vagrant box and have heard that Nginx has some weird caching issues. The way to solve the problem is to set "sendfille off" in the nginx config file.
How can I provision my Laravel/Homestead Vagrant box so that I don't have to ssh into the box and modify the setting?

In your host's homestead folder you can find homestead/scripts/serve.sh. There sendfile is already set to off as default for your app. I think this will set nginx sendfile option to off.
If you still want to edit the nginx.conf permanently, write a line of code into serve.sh to change the config file.
More info on serve.sh
The serve.sh script will run on --provision for any site configured in the Homestead.yaml.
It creates each site in /etc/nginx/sites-available/ and symlinks it to /etc/nginx/sites-enabled/. Nginx and php5-fpm get restarted after that.
In nginx.conf we can see at the end of the http{...}-block has:
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
This includes all sites in /etc/nginx/sites-available/ where the server{...}-blocks are defined. For more information about nginx config look at the Nginx Admin Guide.

Related

How to set up /etc/hosts to access a subfolder like it's a root folder (on a Mac)

I am setting up a new machine. I have it configured to use a Sites folder and localhost to access it. Using Apache, everything installed via Homebrew.
Sites folder
site1
site2
In the browser
localhost/site1/index.html
localhost/site2/index.html
That part works fine.
The problem is that site1 and site2 think localhost is the root folder (which it is) but I want them to think localhost/site1 and localhost/site2 are the root folders for those sites.
Is this something I can do with /etc/hosts or some other trickery?
It turns out this is a combination of /etc/hosts and Apache VirtualHosts. Here are the steps I took:
Establish the directories where you want to serve them from (this will become your DocumentRoot). In my case /Users/myusername/Sites/site1
Edit your /etc/hosts file to include your new "domain name" (this will become your ServerName). In my case site1.com
127.0.0.1 site1.com
::site1.com
Create an Apache Virtual Host ... there are different ways to go about this, but I used Homebrew to install Apache, so for me, there is a file here: /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf. I copied the examples provided using DocumentRoot and ServerName as noted above.
Update this file /opt/homebrew/etc/httpd/httpd.conf to uncomment this line
Include /opt/homebrew/etc/httpd/extra/httpd-vhosts.conf
Restart Apache

set up wildcard subdomain on Ubuntu 18.08 (Laravel/Homestead)

I'm trying to set up wildcard subdomains for a Laravel project in a Laravel/Homestead enviorement, but cannot figure it out why this does not works.
The local setup was successfull, but cannot make it work on the Ubuntu. I've set up in the nginx conf file the server name:
server_name example.test *.example.test
Restarted the nginx, but after accessing any subdomain, there is no activity in access_log.
how can this be done?
It seems, the best/easiest way to solve this is the vagrant-rubydns plugin:
I hope this will help somebody else.

How to resolve domains within a vagrant box?

I have a Debian Vagrant box running a Nginx server which hosts two websites/services that should share data via JSON endpoints.
Websites are accessible with https://app.test and https://cdn.app.test from the browser of the Host MacOS system.
To do this I have setup config.vm.network "private_network", ip: "33.33.33.10" in the Vagrantfile.
I have added to the /etc/hosts file on MacOS:
33.33.33.10 app.test
33.33.33.10 cdn.app.test
I can access both domains from the Mac, that works.
However I cannot use curl https://cdn.app.test/ within the Vagrant box shell because the Domains won't be resolved.
Neither curl_init or file_get_contents work.
I guess the problem is that the Vagrant cannot see the MacOS hosts entries.
What is the right way to configure this dev system? What is the easy fix?
The easy fix is to add
127.0.0.1 app.test
127.0.0.1 cdn.app.test
to /etc/hosts in the Debian Vagrant box.
For Vagrant. copy the default config from /etc/apache2/sites-available/000-default.conf to /etc/apache2/sites-available/"".conf
vagrant ssh // login
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/"<your-test-domain>".conf
Folder name in sites-available should be the exact same as the one that you will be changing in your hosts file later.
Then edit your ServerName and DocumentRoot, enable it -> sudo a2ensite "".conf
restart Apache, edit your hosts file in your host OS.
Inside your hosts file, point to your private IP as specified in Vagrantfile

after homestead provision it delete custom nginx settings in sites-available

I am using homestead with my vagrantbox.
After I vagrant provision, I notice that my nginx sites-available file has been reset. I have to copy and paste again and restart my nginx server.
Any solution it will save it first and copy itself? or in config file can do some setting?

Reload config apache with puppet in vagrant

I set it up a vagrant machine with https://puphpet.com/#.
Everything was OK until I wanted to change the documentroot for an apache vhost:docroot in config.yaml
This change is not reloaded although I run :
vagrant --provision reload
Just run $ vagrant provision, no need to reload.

Resources