2

I have a codeigniter project that runs on xampp. When I run a php command mkdir I get the error "Permission denied". It turns out that the php user and the computer user doesn't have the same name. So I change in the httpd.conf file the lines

User daemon
Group daemon

to

User username
Group daemon

To match my username. Now I get this problem fix but that creates a pemission error on another part of the code. Which is strange because I run the same project on another machine with the same settings and it works. Can you point me on the right direction?

Spy
  • 153
  • 10

1 Answers1

2

The User directive specifies which linux user the httpd process should use to run as. This means the httpd process will do everything as if that user (in this case, you) is doing it. If you don't have permissions to do something, the httpd process won't be able to do it and you will see an error.

To fix this, you need to fix the permissions on the files/folders/commands the httpd process (and php) needs. You can either:

  • grant full permissions to the daemon group on the file/folder you want: chgrp daemon /path/to/file; chmod g+rwx /path/to/file
  • grant full permissions to the specific user on that file/folder: chown username /path/to/file; chmod u+rwx /path/to/file
  • grant full permissions to everyone (probably not recommended): chmod o+rwx /path/to/file

If the process doesn't need to write at that location (mkdir, create or change files, ...) then don't grant write permissions, if it doesn't need to execute (run a command, read a folder's contents) then don't grant execute permissions.

jvdmr
  • 685
  • 5
  • 12