0

I get this error while trying to do file_put_contents().

Apache is working as apache group, started with sudo rights. My user is in apache group. All dirs and files have 755 chmod.

File exists.

Locally it works fine, on remote CentOS server not. Why? How to debug that thing?

Szymon Toda
  • 4,454
  • 11
  • 43
  • 62
  • It's dangerous to give a webserver `sudo` rights and give all files `775` access... – Willem Van Onsem Oct 05 '14 at 14:43
  • 1
    I think he meant he started apache with `sudo apache start` which is the correct way to do it. Apache will start its own threads from the root thread using the configured user. – Rob Oct 05 '14 at 14:49
  • @CommuSoft apache wont start if binding to port 80. Can we get back to my question? – Szymon Toda Oct 05 '14 at 14:53
  • Are you sure you're writing to directory you mean to write to? Can you read data from the same file using the same path? – Schlaus Oct 05 '14 at 15:02
  • Yes path is OK I doublechecked. – Szymon Toda Oct 05 '14 at 15:08
  • maybe local webserver is windows and the remote one is linux which uses different rules for paths. as i recall one uses the `\\` path's the other uses `/` paths. On linux don't start the path with a dot.. it will use the current folder and give issues. – SSpoke Oct 05 '14 at 16:51

2 Answers2

5

Sometimes SELINUX will prevent writing as was my problem serving from Fedora. Run:

sudo setenforce 0
Shadouts
  • 338
  • 2
  • 10
2

This can be solved by changing directory permission.

Run the command like

chmod 777 database (the directory)

You can use getcwd()" to find the directory path.

Please have a look here

Community
  • 1
  • 1
Avinash Babu
  • 6,171
  • 3
  • 21
  • 26