1

Yesterday I've installed a fresh CentOS 7 VM with Apache, MySQL and PHP 7.0.17.

After that, I installed composer and all other required php-packages.

Then I followed this guide to install Firefly-iii : https://firefly-iii.github.io/using-installing.html.

So far so good. The database is migrated and seeded from the php artisan migrate command.

Now the problem, when I try to access the application from the browser, a 500 error appears. No log rules, nothing.

Alright, this might be an permissions problem. I have changed the owner to apache:apache, no result. Set the storage and bootstrap/cache folder to 777 no result.

Alright... What now. Ah, maybe the user or usergroup is incorrect. I've copied my public/index.php and built in some try catch statement (still no log).

When I open the application in the browser finally some result is returned.

This try/catch:

try {
        $response = $kernel->handle(
            $request = Illuminate\Http\Request::capture()
        );
} catch (Exception $e){
        echo $e->getMessage();
        echo '<br/>';
        echo 'User: '.exec('whoami');
        echo '<br/>';
        echo 'Group: '.exec('groups');
        echo '<br/>';
}

returns the following result:

The stream or file "/var/www/html/application-folder/storage/logs/application-name-2017-04-06.log" could not be opened: failed to open stream: Permission denied
User: apache
Group: apache

After this message I've created the /var/www/html/application-folder/storage/logs/application-name-2017-04-06.log file and changed the permissions to 777.

Here is a little piece of my bash history :

[user@16 logs]$ sudo chmod 777 firefly-iii-2017-04-06.log
[sudo] password for user:
[user@16 logs]$ ls -l
-rwxrwxrwx+ 1 apache apache 5 Apr  6 14:18 firefly-iii-2017-04-06.log
[user@16 logs]$ chmod 777 firefly-iii-2017-04-06.log
chmod: changing permissions of ‘firefly-iii-2017-04-06.log’: Operation not permitted

This error messages is still returning and at this moment I've no idea what else I can try to fix this problem.

Does anyone knows a solution or has anybody else expecting this strange behavior?

Please help me, I am completely stuck at this moment and don't know what to do now and how I can solve this problem.

Roy
  • 51
  • 2
  • 10

3 Answers3

1

After a little bit of search yesterday I've found this answer : https://stackoverflow.com/a/37258323/1805919

I've tried it on my own server, and at this moment the application is accessible trough the browser.

Prove this is the problem by turning off selinux with the command

setenforce 0

This should allow writing, but you've turned off added security server-wide. That's bad. Turn SELinux back

setenforce 1

Then finally use SELinux to allow writing of the file by using this command

chcon -R -t httpd_sys_rw_content_t storage

And you're off!

Community
  • 1
  • 1
Roy
  • 51
  • 2
  • 10
0

First of all your server has to be in owner group of application path.

Second you have to set permissions to storage folder. Here is an example how to set permissions on *nix systems:

sudo chmod -R ug+rwx storage bootstrap/cache
Alex Slipknot
  • 2,439
  • 1
  • 18
  • 26
  • Cleared the cache with `php artisan cache:clear` , but didn't help – Roy Apr 06 '17 at 13:57
  • How about clear all cache? `php artisan route:clear && php artisan cache:clear && php artisan config:clear && php artisan view:clear` – Alex Slipknot Apr 06 '17 at 14:00
  • `php artisan route:clear && php artisan cache:clear && php artisan config:clear && php artisan view:clear` `Route cache cleared!` `Cache cleared successfully.` `Configuration cache cleared!` `Compiled views cleared!` Still same error message – Roy Apr 06 '17 at 14:05
  • Nope, unfortunately not. – Roy Apr 06 '17 at 14:29
  • @Roy please check file permissions manually. Maybe it's just not set – Alex Slipknot Apr 06 '17 at 14:37
  • I have checked all files by hand, even with the setfacl command. All files are writable by apache user. – Roy Apr 07 '17 at 06:25
0

Have you tried setting a new application key? Have you also ran your migrations and created the database for the application?