I am using vagrant to run my vm using ubuntu, apache, etc.
This is running on my OSX host.
Everything works fine until my php application tries to create a folder, files within that folder, etc.
I get Permission denied.
What am I missing on the provision / configuration of the vagrant file?
in this case, if you’re using Vagrant + Apache2.
the solution is:
- edit /etc/apache2/apache2.conf;
- Search for User and Group directives
Change these lines to:
User vagrant Group vagrant
sudo service apache2 restart
its not possible to change /vagrant directory owner to www-data (apache user);
Anyway, it works for me.
config.vm.synced_folder "./", "/var/www", owner: "www-data", group: "www-data"
You need to set the owner on the folder that php is trying to write to, to the apache user which is normally www-data… ssh into the vagrant box and try:
sudo chown www-data:www-data <dirname>
That should work… if it does then just add that to what ever provisioner you are using.