Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Error when unit testing
  •  Hi,

     When I run php oil test from the command line I get the fatal error below. I upgraded to version 1.5.1 and made the changes for Monolog. I am sure mu logs folder is writable so I am not sure what is happening:

    Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/home/user/Sites/depot/fuel/app/../logs/2013/02/16.php" could not be opened: failed to open stream: Permission denied' in /home/user/Sites/depot/fuel/packages/log/src/Monolog/Handler/StreamHandler.php:71

  • It says "permission denied", so something must be wrong in that area...
  • When I check the long directory listing for permissions on the file causing the error here is what I get:

    -rw-r--r-- 1 www-data www-data 

    I guess I don't understand who writes to the log file when I run the test: is it the owner which in this case is www-data or is it me as part of the group or other? Also if its the owner is writing the file why am I getting a permission denied error? 
  • it is the user that runs the tests.

    In your case, only the webserver has write access on UID, others only have read access, either through group membership or the world rights.
  • I personally only work with the group. I give that write rights where needed, make sure both the webserver user and all users that need commandline access are member of that group, and set the group 'sticky' so new files automatically get the correct group.
  • How do I do that when log files are created and written dynamically? 
  • HarroHarro
    Accepted Answer
    The sticky bit will be inherited from the directory for new files.

    I use something like this to set the rights on a production FuelPHP installation:

    chown <user>:<group> . -R
    find . -type d -exec chmod 2750 {} \;
    find . -type f -exec chmod 2640 {} \;
    cd fuel\app
    chmod 2770 logs
    chmod 2770 cache
    chmod 2770 config
    cd config
    find . -type d -exec chmod 2770 {} \;
    find . -type f -exec chmod 2660 {} \;

    So the webserver only has write access on logs, cache and config. For a development environment, I use:

    chown <user>:<group> . -R
    find . -type d -exec chmod 2770 {} \;
    find . -type f -exec chmod 2660 {} \;

    so that the group (that contains the development users AND the webserver user) has write access.
  • Thanks I understand the permissions now

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion