Reload config apache with puppet in vagrant - 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.

Related

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?

Disabling XDebug on Primary Vagrant

Is there any simple/correct way to disable Xdebug in a Primary Vagrant box?
I tried setting the xdebug PHP.ini vars in the /manifests/custom/php.pp puppet file, with no luck. Also commenting the xdebug lines in /manifests/init.pp with no luck either.
Any other suggestion?
Find: 'xdebug.ini'
/etc/php/7.0/cli/conf.d/20-xdebug.ini
/etc/php/7.0/fpm/conf.d/20-xdebug.ini
/etc/php/mods-available/xdebug.ini
then comment with ';'
;zend_extension=xdebug.so
then restart your nginx server
sudo service nginx restart

How can I refresh homestead for a new site in my environment?

I'm running Laravel 4 on my development machine (Mac) with homestead and enjoying it thus far but having trouble when adding a new site. The problem is that I add lines like this for a new site in my ~/.homestead/Homestead.yaml file:
folders:
- map: ~/Sites
to: /home/vagrant/Sites
sites:
- map: listingnaples.dev
to: /home/vagrant/Sites/listingnaples.com/public
- map: videocraftersusa.dev
to: /home/vagrant/Sites/videocraftersusa.com/
Then, my /etc/hosts looks like this:
# MY SITES
192.168.10.10 listingnaples.dev
192.168.10.10 videocraftersusa.dev
192.168.10.10 laneyandchris.dev
If i go in and do a homestead destroy followed by homestead up I can access any of those new sites. That deletes my databases though and really sets me back. How do I "refresh" so to speak? If I add myawesomesite.dev to my /etc/hosts, how can I have homestead pick it up?
I tried homestead --provision but that isn't a recognized command.
For what it's worth, in my ~/.homestead/ directory, I do not have a VagrantFile. Not sure where that's at so I can't run a vagrant provision either.
You can also reload the box and the settings
vagrant reload --provision
This reload the box and see if there are changes, if that's the case it will make the changes while reloading
I just ssh using homestead ssh and then add this line
serve domain.app /home/vagrant/Code/path/to/public/directory
where you replace domain.app to your app name, the same you use on your yaml file and your path to your new public site directory, then just homestead up and you could see it active.
Try run vagrant global-status. You'll see the list of running boxes at this time, like this:
MacBook-Pro-lancedikson:~ lancedikson$ vagrant global-status
id name provider state directory
------------------------------------------------------------------------------------------
9710b02 default virtualbox running /Users/lancedikson/.composer/vendor/laravel/homestead
The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"
That's all. Now run vagrant provision 9710b02 and it will be provisioned.
As of Laravel 5 and more importantly Homestead 2.0, just run:
homestead up
Then:
homestead provision
You have to use vagrant provision anyway from the same directory where Homestead.yaml is.
You can run:
homestead up --provision
In my case I had a Homestead.yaml in ~/.homestead/ and in ~/Homestead/.
I am not sure if the default location changed or that I changed it manually (maybe because I did not like the hidden dir), but make sure you don't have multiple Homestead.yaml files. I now symlinked them so I can not confuse myself any further.
But normally, homestead provision or homestead up --provision (when it was turned off) should do.

Vagrant/Virtualbox Nginx Provisioning

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.

Resources