Solve 500 response Laravel (Uncaught UnexpectedValueException: Laravel.log) - laravel-5

I have a problem with my (new/clean) Laravel (tried v5.2 and v5.5) application on Centos 7. It shows a 500 error when i visited the URL of the application with no error. I checked the log file of apache (/etc/httpd/logs/error-log.log) what contained the 2 errors bellow:
[Mon Dec 04 10:32:34.108956 2017] [:error] [pid 25889] [client 192.168.1.240:63437] PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/public/blog_project/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)\n#1 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#2 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array)\n#3 /var/www/public/blog_project/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(UnexpectedValueException), Array)\n#4 /var/www/public/blog_project/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('error', Object(U in /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
&
[Mon Dec 04 10:32:34.109334 2017] [:error] [pid 25889] [client 192.168.1.240:63437] PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/public/blog_project/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)\n#1 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#2 /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)\n#3 /var/www/public/blog_project/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)\n#4 /var/www/public/blog_project/vendor/laravel/framework/src/Illuminate/Log/Writer.p in /var/www/public/blog_project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
To solve these problems i Googled a lot. Solutions i found where all related to permissions so I tried to set chmod 777 to all directories and files (for test purposes, not recommended at live environment!) in /var/www/public/blog_project but this did not solve the problem.
I also found that the owner/group could be the problem (unlikely with chmod 777 but ok) so I changed the owner and group to "apache". Unfortunately this did still not solve my problem.
I also tried a "php artisan cache:clear" (suggested in some topic what described the same problem as i have)

At the moment of writing i already had found the solution (after many hours of Googling) for my problem but i still want to post this question because i could not find another question what solved my problem. I hope to help other people who have the same problem this way.
The problem was that SELinux was enabled which prevent Apache to write files even with 777 mode. It seems that SELinux is active by Centos 4 or higher by default. I also found that Fedora has SELinux activated what results in the same problem (no own experience with Fedora).
I solved the problem by disabling SELinux. For CentosOS7 id did this by editing /etc/sysconfig/selinux
and changing the line SELINUX=enforcing into SELINUX=disabled. After that i rebooted the server and the problem was solved.

I solved the problem by disabling SELinux. For CentosOS7 id did this by editing /etc/sysconfig/selinux and changing the line SELINUX=enforcing into SELINUX=disabled. After that i rebooted the server and the problem was solved.
Thanks :)

please don't disable your selinux. there is a better way to do it
See this, i posted a better way Laravel: file_put_contents() failed to open stream: Permission denied for Session folder

Related

How To Solve This Problem I am New For Laravel

Warning: Unknown: Failed to open stream: No such file or directory in Unknown on line 0 Fatal error: Failed opening required 'D:\next-laravel\vendor\laravel\framework\src\Illuminate\Foundation\Console/../resources/server.php' (include_path='C:\xampp\php\PEAR') in Unknown on line
The problem can have several causes. One of the most common causes is an antivirus in the background. It sees the server.php as malicious and simply removes it. Check your antivirus and restore the removed server.php.
Check your antivirus and add the file (server.php) as an exception.
E.g. In Avast Antivirus, go to the quarantine folder and add an exception to the file or folder you are working with.
This will help resolve the error

how do i use the laravel talk functionality

i want to add a user conversation function in my app, but i am having problems installing the talk functionality. i have downloaded the project from github, but i was unable to use it because of this two errors
Warning: require(C:\xampp\htdocs\tok\bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\tok\bootstrap\autoload.php on line 17
Fatal error: require(): Failed opening required 'C:\xampp\htdocs\tok\bootstrap/../vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\tok\bootstrap\autoload.php on line 17. is there a way out of???
does anyone know how use the talk functionality by nahid??
You just need to run the following in the project folder:
Composer Install
Here is a question with a similar issue that might help you get to the root cause: (possible duplicate question)
Laravel 5 Failed opening required bootstrap/../vendor/autoload.php

Magento before install on centos 7 getting 500 internal server error

Hi I am trying to install magento 1.9.x and magento2 in my centos operating system.. the following links help to configure apache2.4, php7 and mysql5.7 in centos.
Install magento link
after configure web server, php, mysql, magento files and all. I create database for magento2. Based on above link i did all steps one-by-one. After i run in browser localhost/magento2/
it show 500 Internal server error in firebug and blank browser.
I am beginner of centos and magento
Please any one help how to solve this problem i was spend past two days.
Apache error log:
[Sat Sep 10 14:22:33.728848 2016] [:error] [pid 2809] [client
::1:45432] PHP Fatal error: Uncaught Zend_Cache_Exception: cache_dir
"/var/www/html/magento2/var/page_cache" is not writable in
/var/www/html/magento2/vendor/magento/zendframework1/library‌​/Zend/Cache.php:209\‌​nStack
trace:\n#0
/var/www/html/magento2/vendor/magento/zendframework1/library‌​/Zend/Cache/Backend/‌​File.php(180):
Zend_Cache::throwException('cache_dir "/var...')\n#1
/var/www/html/magento2/vendor/colinmollenhour/cache-backend-‌​file/File.php(87):
Zend_Cache_Backend_File->setCacheDir('/var/www/html/m...')\n‌​#2
/var/www/html/magento2/vendor/magento/zendframework1/library‌​/Zend/Cache.php(153)‌​:
Cm_Cache_Backend_File->__construct(Array)\n#3
/var/www/html/magento2/vendor/magento/zendframework1/library‌​/Zend/Cache.php(94):
Zend_Cache::_makeBackend('Cm_Cache_Backen...', Array, true, true)\n#4
/var/www/html/magento2/lib/internal/Magento/Framework/App/Ca‌​che/Frontend/Factory‌​.php(158):
Zend_Cache::factory('Magento\\Framewo...', 'Cm_Cache_Backen...',
Array, Array, true, true, true)\n#5
/var/www/html/magento2/lib/internal/Magento/Framework/App/Ca‌​che/Frontend
in
/var/www/html/magento2/vendor/magento/zendframework1/library‌​/Zend/Cache.php
on line 209
To me this look like the main problem:
Uncaught Zend_Cache_Exception: cache_dir
"/var/www/html/magento2/var/page_cache" is not writable in /var/www/html/magento2/vendor/magento/zendframework1/library‌​/Zend/Cache.php:209\‌​nStack
You have the wrong permissions or wrong owner for this folder. You can fix this using chown for fixing the owner of that folder or chmod for fixing writing permissions for that folder.
Try this:
chown -R apache.apache /var/www/html/magento2/
This sets the whole magento2 folder to have apache as owner and group. It is not the best security measure but for testing is fine.

Magento Autoload.php cannot find other PHP scripts

I keep getting this kind of error since I moved Magento from my server to clients server:
exception 'Zend_Validate_Exception' with message 'Validate class not found from basename 'NotEmpty'' in /lib/Zend/Validate.php:244
Caused by:
Warning: include(NotEmpty.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /lib/Varien/Autoload.php on line 93
This one I get when I try to finish my order.
I got one similar yesterday when trying to create an attribute.
Warning: include(StringLength.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in /lib/Varien/Autoload.php on line 93
I checked for permissions and all the files referred by the error have 777 and all the folders from root to those files have also 777.
Any thoughts?
EDIT:
I followed the hint from the comments and I managed to find the path of the file causing the error. The NotEmpty.php is called from the root of Magento though it should have been in /lib/Zend/Validate/.
Any idea how to get the right path?

Magento error after moving website to another server

I just transferred my website to another server by using this guide: http://www.atwix.com/magento/moving-magento-to-another-server/
but when i access the it gives me this error. What does it means? what do i need to do to make it work?
Warning: include(Zend/Log.php) [function.include]: failed to open stream: No such file or directory in /var/www/site/lib/Varien/Autoload.php on line 93
Warning: include() [function.include]: Failed opening 'Zend/Log.php' for inclusion (include_path='/var/www/site/app/code/local:/var/www/site/app/code/community:/var/www/site/app/code/core:/var/www/site/lib:.:/usr/share/php:/usr/share/pear') in /var/www/site/lib/Varien/Autoload.php on line 93
Fatal error: Class 'Zend_Log' not found in /var/www/site/app/code/core/Mage/Core/functions.php on line 247
As far as i can see, it looks like the file in question can't be found at all. What to do is check the directory /www/work/newshop/lib/Zend and make sure the log file is within there. If not, double check your previous server and see if it's there as well. It's possible for you to have just missed it.
If it IS there, make sure permissions are set accordingly. eg; the log.php file should have it's permissions set to 644. (Read and Write for owner, Read for group and read for public)
did you remove the cache folder from Magento After moved your installation?
And wich PHP Version ist installed on the new Server?
Magento have already problem with php5.4 and php5.5 (reference: https://bugs.php.net/bug.php?id=62639)

Resources