This is an article where an error generated as ‘views folder permission denied’ at the time of the web application based on Laravel 5.3 framework is being executed. This error actually appeared when the web application based on Laravel 5.3 framework is executed. The error appeared as shown in the image below :
An error which is displayed in the image above can be found in the error log named ‘laravel.log’ stored in the default folder where the log dedicated for web application based on Laravel 5.3 framework, it is located in storage/logs :
[2017-02-12 16:39:57] local.ERROR: ErrorException: file_put_contents(/var/www/html/laravel-project/storage/framework/views/B6BETDiE1wtExOa5pXJJjPLFcLWXAzEyP6iTG8B6): failed to open stream: Permission denied in /var/www/html/laravel-project/vendor/laravel-project/framework/src/Illuminate/Filesystem/Filesystem.php:111 Stack trace: #0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'file_put_conten...', '/var/www/html/i...', 111, Array) #1 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php(111): file_put_contents('/var/www/html/i...', 'a:4:{s:6:"_toke...', 2) #2 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Session/FileSessionHandler.php(83): Illuminate\Filesystem\Filesystem->put('/var/www/html/i...', 'a:4:{s:6:"_toke...', true) #3 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Session/Store.php(262): Illuminate\Session\FileSessionHandler->write('B6BETDiE1wtExOa...', 'a:4:{s:6:"_toke...') #4 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(88): Illuminate\Session\Store->save() #5 /var/www/html/laravel-project/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\Session\Middleware\StartSession->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response)) #6 /var/www/html/laravel-project/public/index.php(58): Illuminate\Foundation\Http\Kernel->terminate(Object(Illuminate\Http\Request), Object(Illuminate\Http\Response)) #7 {main}
The error message is actually very precise, which is the views folder permission denied. It is probably because the permission is not enough for even the folder to be accessed and to be written. That part of error can be seen in the following part of log :
[2017-02-12 16:39:57] local.ERROR: ErrorException: file_put_contents(/var/www/html/laravel-project/storage/framework/views
Apache Webserver or any webserver used to execute the script is actually cannot performed the operation of ‘file_put_contents’ in the folder of ‘/var/www/htm/laravel-project/storage/framework/views.
To solve the above problem arises, there are several steps or approaches which can be used. The first things is to change the permission setting so that Apache Webserver or any webserver utilized for executing web application based on Laravel 5.3 framework can execute or write into it properly.
1. Make sure that the owner,indeed user and even the group owner of the folder is owned by Apache webserver or any webserver used. This rule is somehow applied in UNIX or Linux operating system.
2. After doing the first step, try to change the folder permissions into 777. This rule is also applied in UNIX or Linux operating system. In other words, make this folder writable as it can also be done in other operating system.
3. Another step which can be done is by checking the status of SELinux applied in the operating system. If SELinux feature is activated or it is in the ‘enforced’ state. Make sure that the security label of the folder somehow permitted by SELinux to be written. Read the article titled ‘Using SELinux for Security Context Labeling‘ which can be visited in this link.
To make it short, just type the following command to change the security label :
chcon -Rv -t httpd_sys_rw_content_t views/
The above command can be translated as change the security context of the folder named views recursively into ‘httpd_sys_rw_content_t’.
One thought on “Views folder permission denied in Laravel 5.3”