Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We have moved our website to a new server (Ubuntu 12.04 LTS) which I had set up with ISPConfig 3.

The Problem:

Everything works fine, but PHP gives me a "failed to open stream: Permission denied"-warning when trying to write new log-files to existing log-files.

I'm very insecure yet about playing around with stuff because I'm not quite familiar with Linux yet. Right now, all files and folders of my website have the owner "web1" from the group "client1". The permissions on the log-directory are the same as before (on the old host).

I'm aware that Apache (and PHP?) runs as its own user "www-data", so basically, I would have to tell my log-files and folders that it is ok to be read/written by this user, right?

What I (would) have tried:

While researching, I bumped into this post talking about creating a common group for the owner of the files (web1) and the apache-user (www-data).

I have also found the following instructions to do so:

//Create new group
$ sudo addgroup webdev

//Change the group of your web directory:
$ sudo chgrp -R webdev /var/www/
$ sudo chmod -R g+rw /var/www/

//Set the guid bit on all folders in your web directory:
$ sudo find /var/www -type d -exec chmod +s {} \;

//Add Apache to the webdev group:
$ sudo usermod -a -G webdev www-data

//Add your user to the webdev group:
$ sudo usermod -a -G webdev <user_name>

But I haven't tried it yet because I'm not sure what

$ sudo find /var/www -type d -exec chmod +s {} \;

does. Is this even the correct approach to my problem?

share|improve this question

closed as off-topic by HopelessN00b Mar 8 '15 at 20:45

  • This question does not appear to be about server, networking, or related infrastructure administration within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

Not trying to talk down, just breaking it all down.

sudo - run this command as a super user
find - look for something... 
/var/www - the /var/www directory...
-type d  - ...that is a directory...
-exec chmod +s - ...and executes a chmod (change mode) +s (set the user bit) ...
{} - ...for every directory you find...
\; - and end the command.

now the commands listed above look fine if that is what you want to do. Creating a common group with apache and others. Hope that helps

share|improve this answer
Thank you very much, this actually makes sense :-D I guess I was confused by the +s-parameter (I olny know things like chmod u+r). I'm actually not sure if this is what I want because I'm not familiar enough with Linux to figure out what exactly the problem is. My assumption was that "www-data" can't write to the property of "web1" because it is not allowed to, but if I put them both in one group with read+write permissions it should solve the problem - right? – Quasdunk Sep 19 '12 at 13:39
Correct. By being in the same group they can write to things owned by the same group even if the owner is different like say root. – Nate Sep 19 '12 at 14:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.