PuPHPet and Vagrant are awesome. If you develop on Windoze, you are either off your head, or have no choice in the workplace. Right now I fall into the latter category. I noticed XAMPP installed. Yeah right. No chance. Anyway, using PuPHPet and Vagrant is a far better way of doing things regardless of your OS, as it means you can move your entire development environment anywhere without having to reconfigure anything! See my post https://delboy1978uk.wordpress.com/2014/08/18/using-puphpet-and-vagrant/ for info on getting set up and running.
Anyway, it turns out that the files and directories for your sites are all owned by www-data, and are in the www-data group. I was trying to run a PHP CLI command, however, as the logged in user is vagrant and the permissions were only executable for the owner, I tried running chmod, and chgroup, and chown, with no success. Because these are mounted folders and not actually in the VM, altering the permissions the normal way is impossible.
The solution is to go into your VagrantFile, and add the following:
config.vm.synced_folder "./mysite/scripts", "/var/www/mysite/scripts", owner: "www-data", group: "www-data", mount_options: ["dmode=775,fmode=775"]
The first path given is relative to your host OS directory with your site folders inside, the second path is the path on the VM. dmode I’m guessing is the directory permissions, fmode is the file permissions. I keyed this in just before the ‘end’ line at the bottom of the VagrantFile.
To make the changes, you can type vagrant up (if you havent started yet), or vagrant reload. Permissions have now been changed!
One last thing. Once I was able to execute, I ran my script and got
: No such file or directory
This again is a stupid character encoding issue due to windows, and the way I sorted it was to cat the file in Putty, and select the text, nano a new file, paste it in, delete the original, and rename the new file. I didnt have to chmod anything, all files in here now default to 775.
Anyway, now that problem has been solved I can get back on with my work! Cheers! 😀
It appears that the Vagrant file has been broken up into smaller more specific parts. In a recent puPHPet Vagrant box, I had to paste it in the puphpet/vagrant/vagrantfile-local file, right before the very last line (which just says end).