Update:
php artisan serve works fine on windows with the same configuration. but native php and apache can't handle that.
Laravel 5.4 on CentOS 7 and PHP 7 (Production)
I'm trying to deploy a laravel application on centos 7, but every time I get 500 internal error. the httpd log says "Permission Denied on writing on 'storage/log/laravel.log' by Monolog", but I already tried every possible option and solution, like giving storage 775 or 777 permission, changing the owner to 'apache:apache', clearing cache and dump. but none of them did the job. I'm really exhausted. I even tried on php 5.6 but that didn't fix it either. please help :(
file permissions:
-rw-r--r--. 1 apache apache 555 May 3 12:33 webpack.mix.js
drwxr-xr-x. 4 apache apache 83 May 3 12:33 tests
drwxrwxr-x. 5 apache apache 46 May 3 12:33 storage
-rw-r--r--. 1 apache apache 563 May 3 12:33 server.php
drwxr-xr-x. 2 apache apache 75 May 3 12:33 routes
drwxr-xr-x. 5 apache apache 45 May 3 12:33 resources
-rw-r--r--. 1 apache apache 3.4K May 3 12:33 readme.md
drwxr-xr-x. 4 apache apache 116 May 3 12:33 public
-rw-r--r--. 1 apache apache 1.1K May 3 12:33 phpunit.xml
-rw-r--r--. 1 apache apache 1.1K May 3 12:33 package.json
drwxr-xr-x. 5 apache apache 72 May 3 12:33 database
drwxr-xr-x. 2 apache apache 209 May 3 12:33 config
-rw-r--r--. 1 apache apache 1.3K May 3 12:33 composer.json
drwxr-xr-x. 3 apache apache 54 May 3 12:33 bootstrap
-rw-r--r--. 1 apache apache 1.7K May 3 12:33 artisan
drwxr-xr-x. 6 apache apache 84 May 3 12:33 app
-rw-r--r--. 1 apache apache 119K May 3 12:39 composer.lock
drwxr-xr-x. 31 apache apache 4.0K May 3 12:39 vendor
httpd error
[Wed May 03 18:02:16.363242 2017] [:error] [pid 71379] [client 192.168.254.1:55383] PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/dca-core/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/html/dca-core/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /var/www/html/dca-core/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/html/dca-core/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /var/www/html/dca-core/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#3 /var/www/html/dca-core/vendor/laravel/framework/src/Illuminate/Log/Writer.php(203): Monolog\\Logger->error(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#4 /var/www/html/dca-core/vendor/laravel/framework/src/Illuminate/Log/Writer.php(114): in /var/www/html/dca-core/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
httpd.conf
DocumentRoot "/var/www/html/dca-core/public"
<Directory "/var/www/html/dca-core/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Yeah - but it's not very friendly, sadly :-/ It's something like the below - but my selinux-foo is fading fast as I usually give in and disable it (and feel guilty, but there we go) :
semanage fcontext -a -t 'httpd_cache_t' '/path/to/your/storage(/.*)?'
restorecon -Rvvv /path/to/your/storage
But you might want to google about and see if there's some better selinux advice :-)
Please or to participate in this conversation.