2

I'm usuing Ubuntu 12.04LTS and have created an apache virtual host in my local file system for a site I'm developing. However, when apache tries to access the site, it can't because the ownerships are all in my own username and not www-data. So I changed all the ownerships:

$ chown -R www-data:www-data domain-root-name

Apache is now happy, but I'm not, because I can no longer do anything with the files - which I need to do for development purposes.

I tried doing the reverse (adding www-data to my own group), but that just meant that apache could no longer access the site.

There's lots of stuff about this all over the place but nothing works for me. Mainly the suggestion is to add yourself to the www-data group. This is not sufficient, however, as I still can't edit the site's files.

The other suggestion is to set all permissions to 777, which makes lots of respondents hold their hands up in horror, even though it (obviously) works.

Is there anyone out their who has solved this problem so that a developer can develop safely on a local apache installation?

2 Answers 2

2

Personally, I set myself as the owner with www-data as the group:

sudo chown -R konapun:www-data domain-root-name

and then set the permissions to 754 (konapun: rwx, www-data: rx, other: r):

sudo chmod -R 754 domain-root-name

If Apache has to create any files (temporary files, or maybe a templating engine which compiles templates), I set those individual directories to 774.

1
  • Makes sense and is safer than 777. I'll give it a go. Thank you.
    – Peter
    Nov 26, 2013 at 17:30
1

I think I may have found an answer:

http://www.vagrantup.com/

Vagrant is open source under a very permissive license (MIT).

I haven't tried out every possible situation (for example automatically updating or adding a plugin to a development WordPress site), but the small amount of testing that I have done seems to indicate that I can leave the apache permissions at their default values in the vagrant VM and work in a Vagrant folder on the host (my development box) without any problems of access. The permissions on any apache installation on the host are irrelevant to this, and unaffected by anything you do.

You do have to use a non-standard port for the site you're developing, like 8080. If you're using port-mapping (just a single extra line in the vagrant VM's config file) this sends requests on this port to the VM's port 80 assuming that's what you've specified in the config file. And you would need to create a new VM for each project, but that's hardly the end of the world.

From the little time I've spent using vagrant (just a day or so) it seems to be a very elegant and easy-to-use solution for this and other problems.

If anyone has any other pros and cons I'd be interested to hear them.

1
  • vagrant rocks! Just make sure the app your developing doesn't need special permissions within the document root..
    – Erik
    Apr 28, 2014 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .