Laravel 5: unstable display errors - php

I have a weird issue, Laravel 5 sometimes display <HTML> </ HTML> rather than display error msg, and next time when refresh display the error correctly,
using: Amazon EC2, Ubuntu 16.04, PHP7
Any suggestion? thanks,
Updates: storage permissions:
Updates: Laravel log
[2017-03-12 13:19:07] local.ERROR: Tymon\JWTAuth\Exceptions\JWTException: A token is required in /var/www/html/api/vendor/tymon/jwt-auth/src/JWTAuth.php:299
Stack trace:
#0 /var/www/html/api/vendor/tymon/jwt-auth/src/JWTAuth.php(188): Tymon\JWTAuth\JWTAuth->requireToken(NULL)
#1 /var/www/html/api/vendor/tymon/jwt-auth/src/JWTAuth.php(124): Tymon\JWTAuth\JWTAuth->getPayload(NULL)
#2 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(221): Tymon\JWTAuth\JWTAuth->authenticate(NULL)
#3 /var/www/html/api/app/Http/Middleware/info.php(21): Illuminate\Support\Facades\Facade::__callStatic('authenticate', Array)
#4 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): App\Http\Middleware\info->handle(Object(Illuminate\Http\Request), Object(Clos$
#5 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\H$
#6 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(30): Illuminate\Routing\Pipeline->Illuminate\Routing\{cl$
#7 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Illumi$
#8 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\H$
#9 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing\{clo$
#10 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Illumi$
#11 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\$
#12 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Rout$
#13 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(148): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object$
#14 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\$
#15 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(102): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\$
#16 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(149): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#17 /var/www/html/api/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illu$
#18 /var/www/html/api/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#19 {main}
Server Response details:
Status Code: 200 OK
Connection: Close
Content-Type: text/html
Pragma: no-cache
refresh: 1; URL=http://54.200.51.42/api/public/login

Check your storage folder:
Already have permission for write: chown, chmod
Have folder framework/sessions or not
And try to
sudo chmod -R 777 storage
sudo chown -R ec2-user:ec2-user storage
sudo chmod -R 777 storage/framework/sessions
sudo chown -R ec2-user:ec2-user storage/framework/sessions

Related

Laravel shows 'Permission denied' after local package added

I have successfully installed Laravel 8 in Ubuntu 20.4 (Apache server) and the home page is shown correctly. Then, I have added my local repository to composer.json:
"repositories": [
{
"type": "path",
"url": "/home/kari/kama-web-service"
}
]
and it successfully have installed composer require mypackage/name:
.
.
Discovered Package: mypackage/name
.
.
after that the following error is shown on home page:
ErrorException: include(/var/www/html/rws2/vendor/composer/../mypackage/name/src/KamaWebServiceProvider.php): failed to open stream: Permission denied in file /var/www/html/rws2/vendor/composer/ClassLoader.php on line 480
#0 /var/www/html/rws2/vendor/composer/ClassLoader.php(480): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()
#1 /var/www/html/rws2/vendor/composer/ClassLoader.php(480): include()
#2 /var/www/html/rws2/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile()
#3 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#4 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(735): spl_autoload_call()
#5 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(669): Illuminate\Foundation\Application->resolveProvider()
#6 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\Foundation\Application->register()
#7 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(649): Illuminate\Foundation\ProviderRepository->load()
#8 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#9 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(237): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap()
#10 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(152): Illuminate\Foundation\Application->bootstrapWith()
#11 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(136): Illuminate\Foundation\Http\Kernel->bootstrap()
#12 /var/www/html/rws2/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(110): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
#13 /var/www/html/rws2/public/index.php(52): Illuminate\Foundation\Http\Kernel->handle()
#14 {main}
I'm absolutely sure that the file /var/www/html/rws2/vendor/composer/../mypackage/name/src/KamaWebServiceProvider.php exists.
At first I thought that I should give rw access to my package at /home/kari/kama-web-service so I ran chmod -R 775 /home/kari/kama-web-service and sudo chown -R $USER:www-data /home/kari/kama-web-service commands but nothing happen!
Any idea?
The problem goes back to the issue of ‍‍‍‍‍‍‍‍‍/home/kari permissions. To solve it I ran also:
sudo chown -R $USER:www-data /home/kari

500 Error with laravel when creating a new project

I try to learn laravel and after creating a project with.
i created a new project by typing "laravel new projectname" in cmd, installing composer and node.js, changed in cmd to the project directory and installed composer there and tryed to run "php artisan serve" comand. i got the message "Laravel development server started: http://127.0.0.1:8000"
when i open http://127.0.0.1:8000 i get a 500 Error (not from the browser. the error is from laravel).
I have absolutly no idea what could be wrong. I went by 3 guides for starters and they did not have this problem.
Is there anything i can do ti fix this error?
thank you very much in advance
edit: here is the logfile from storage/logs
[2019-10-12 20:13:12] production.ERROR: No application encryption key has been specified. {"exception":"[object] (RuntimeException(code: 0): No application encryption key has been specified. at C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\EncryptionServiceProvider.php:44)
[stacktrace]
#0 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\helpers.php(424): Illuminate\\Encryption\\EncryptionServiceProvider->Illuminate\\Encryption\\{closure}(NULL)
#1 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\EncryptionServiceProvider.php(48): tap(NULL, Object(Closure))
#2 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Encryption\\EncryptionServiceProvider.php(24): Illuminate\\Encryption\\EncryptionServiceProvider->key(Array)
#3 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(800): Illuminate\\Encryption\\EncryptionServiceProvider->Illuminate\\Encryption\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
#4 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(682): Illuminate\\Container\\Container->build(Object(Closure))
#5 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(630): Illuminate\\Container\\Container->resolve('encrypter', Array)
#6 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(768): Illuminate\\Container\\Container->make('encrypter', Array)
#7 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(946): Illuminate\\Foundation\\Application->make('encrypter')
#8 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(874): Illuminate\\Container\\Container->resolveClass(Object(ReflectionParameter))
#9 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(835): Illuminate\\Container\\Container->resolveDependencies(Array)
#10 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(682): Illuminate\\Container\\Container->build('App\\\\Http\\\\Middle...')
#11 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Container\\Container.php(630): Illuminate\\Container\\Container->resolve('App\\\\Http\\\\Middle...', Array)
#12 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Application.php(768): Illuminate\\Container\\Container->make('App\\\\Http\\\\Middle...', Array)
#13 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(215): Illuminate\\Foundation\\Application->make('App\\\\Http\\\\Middle...')
#14 C:\\Users\\Rjinxil\\testproject\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php(189): Illuminate\\Foundation\\Http\\Kernel->terminateMiddleware(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#15 C:\\Users\\Rjinxil\\testproject\\public\\index.php(60): Illuminate\\Foundation\\Http\\Kernel->terminate(Object(Illuminate\\Http\\Request), Object(Illuminate\\Http\\Response))
#16 C:\\Users\\Rjinxil\\testproject\\server.php(21): require_once('C:\\\\Users\\\\Rjinxi...')
#17 {main}
"}
So close your terminal session and run this command in your CMD:
php artisan key:generate
in the project folder. Make sure you have .env file created. Then serve your application once again.
Try Below steps :
php artisan config:cache
php artisan cache:clear
php artisan key:generate

Yii2 migration can't find database

I'm trying to migrate two table from extension created by me. I've created it on XAMPP and my migration worked fine there ( tested it few times ). Then I decided to test it on another server and what I get as an error is:
Exception 'yii\db\Exception' with message 'SQLSTATE[HY000] [1045] Access denied for user 'ivailo'#'localhost' (using password: YES)'
in Z:\extension\slide\vendor\yiisoft\yii2\db\Connection.php:624
Stack trace:
#0 Z:\extension\slide\vendor\yiisoft\yii2\db\Connection.php(996): yii\db\Connection->open()
#1 Z:\extension\slide\vendor\yiisoft\yii2\db\Connection.php(983): yii\db\Connection->getMasterPdo()
#2 Z:\extension\slide\vendor\yiisoft\yii2\db\Command.php(253): yii\db\Connection->getSlavePdo()
#3 Z:\extension\slide\vendor\yiisoft\yii2\db\Command.php(1143): yii\db\Command->prepare(true)
#4 Z:\extension\slide\vendor\yiisoft\yii2\db\Command.php(399): yii\db\Command->queryInternal('fetchAll', NULL)
#5 Z:\extension\slide\vendor\yiisoft\yii2\db\mysql\Schema.php(312): yii\db\Command->queryAll()
#6 Z:\extension\slide\vendor\yiisoft\yii2\db\mysql\Schema.php(125): yii\db\mysql\Schema->findColumns(Object(yii\db\TableSchema))
#7 Z:\extension\slide\vendor\yiisoft\yii2\db\Schema.php(744): yii\db\mysql\Schema->loadTableSchema('migration')
#8 Z:\extension\slide\vendor\yiisoft\yii2\db\Schema.php(194): yii\db\Schema->getTableMetadata('{{%migration}}', 'schema', true)
#9 Z:\extension\slide\vendor\yiisoft\yii2\console\controllers\MigrateController.php(210): yii\db\Schema->getTableSchema('{{%migration}}
', true)
#10 Z:\extension\slide\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(875): yii\console\controllers\MigrateControlle
r->getMigrationHistory(NULL)
#11 Z:\extension\slide\vendor\yiisoft\yii2\console\controllers\BaseMigrateController.php(166): yii\console\controllers\BaseMigrateContr
oller->getNewMigrations()
#12 [internal function]: yii\console\controllers\BaseMigrateController->actionUp(0)
#13 Z:\extension\slide\vendor\yiisoft\yii2\base\InlineAction.php(57): call_user_func_array(Array, Array)
#14 Z:\extension\slide\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#15 Z:\extension\slide\vendor\yiisoft\yii2\console\Controller.php(148): yii\base\Controller->runAction('up', Array)
#16 Z:\extension\slide\vendor\yiisoft\yii2\base\Module.php(528): yii\console\Controller->runAction('up', Array)
#17 Z:\extension\slide\vendor\yiisoft\yii2\console\Application.php(180): yii\base\Module->runAction('migrate/up', Array)
#18 Z:\extension\slide\vendor\yiisoft\yii2\console\Application.php(147): yii\console\Application->runAction('migrate/up', Array)
#19 Z:\extension\slide\vendor\yiisoft\yii2\base\Application.php(386): yii\console\Application->handleRequest(Object(yii\console\Request
))
#20 Z:\extension\slide\yii(23): yii\base\Application->run()
#21 {main}
My Yii2 is fresh installed one. Only added the extension via composer. Database configuration is correct ( user and password that we are using for years ). I've created test table and executed one line Yii::$app->db->createCommand('INSERT INTO test VALUES (1,'testname')') and that passed fine. That way I decide that the connection is ok. But with console migration php yii migrate/up --migrationPath=#vendor/********/*******/migrations it gave me the error above. Want to mention that I am not familiar with our server configurations ( All I know is OS: Ubuntu 14.04 H: Apache2 ) and system administrating at all if the problem is about that somehow. Thank you in advance!

dbModel read resource does not implement Zend_Db_Adapter_Abstract on magento EE

I know this questions is asked so many times but none of the answers is working for me this time.
Everytime I try to load my magento EE 1.14.2.0 I get:
dbModel read resource does not implement Zend_Db_Adapter_Abstract
Trace:
#0 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Resource/Db/Collection/Abstract.php(134): Varien_Data_Collection_Db->setConnection(false)
#1 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Config.php(1348): Mage_Core_Model_Resource_Db_Collection_Abstract->__construct(Object(Mage_Core_Model_Resource_Website))
#2 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Config.php(1380): Mage_Core_Model_Config->getModelInstance('core_resource/w...', Object(Mage_Core_Model_Resource_Website))
#3 /var/www/vhosts/receptional/htdocs/app/Mage.php(491): Mage_Core_Model_Config->getResourceModelInstance('core/website_co...', Object(Mage_Core_Model_Resource_Website))
#4 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Abstract.php(208): Mage::getResourceModel('core/website_co...', Object(Mage_Core_Model_Resource_Website))
#5 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/Abstract.php(213): Mage_Core_Model_Abstract->getResourceCollection()
#6 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/App.php(608): Mage_Core_Model_Abstract->getCollection()
#7 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/App.php(466): Mage_Core_Model_App->_initStores()
#8 /var/www/vhosts/receptional/htdocs/app/code/core/Mage/Core/Model/App.php(349): Mage_Core_Model_App->_initCurrentStore('swimshop', 'store')
#9 /var/www/vhosts/receptional/htdocs/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#10 /var/www/vhosts/receptional/htdocs/index.php(83): Mage::run('swimshop', 'store')
#11 {main}
I have tried updating permissions for var and media folder to 777 but no luck, I also tried updating permission of my whole magento to 777 but no luck again.
Just to let you know that I am on Nginx server if that helps.
Though you are able to run chmod -R 777 files permissions, it may not be working properly. This error comes because of file permission issues.
Check if SELinux is in permissive mode or not?
sestatus
If it is not in permissive mode use following.
Running the following command should fixe the issue.
chcon -Rv --type=httpd_sys_content_t <web Directry>

Laravel: Permission denied in laravel Blade File

I have the following issue when trying to install Laravel http://laravel.com
Any help, would be greatly appreciated.
Unhandled Exception
Message:
file_put_contents(/Users/alvincrespo/Sites/apollo/storage/views/26bdebca7505781c753aa21663170a1b)
[function.file-put-contents]: failed to open stream: Permission denied
Location:
/Users/alvincrespo/Sites/apollo/laravel/blade.php on line 63 Stack
Trace:
#0 /Users/alvincrespo/Sites/apollo/laravel/laravel.php(40):
Laravel\Error::native(2, 'file_put_conten...', '/Users/alvincre...',
63) #1 [internal function]: Laravel{closure}(2,
'file_put_conten...', '/Users/alvincre...', 63, Array) #2
/Users/alvincrespo/Sites/apollo/laravel/blade.php(63):
file_put_contents('/Users/alvincre...', '...') #3 [internal
function]: Laravel{closure}(Object(Laravel\View)) #4
/Users/alvincrespo/Sites/apollo/laravel/event.php(199):
call_user_func_array(Object(Closure), Array) #5
/Users/alvincrespo/Sites/apollo/laravel/event.php(138):
Laravel\Event::fire('laravel.view.en...', Array, true) #6
/Users/alvincrespo/Sites/apollo/laravel/view.php(325):
Laravel\Event::until('laravel.view.en...', Array) #7
/Users/alvincrespo/Sites/apollo/laravel/view.php(546):
Laravel\View->render() #8
/Users/alvincrespo/Sites/apollo/laravel/response.php(246):
Laravel\View->__toString() #9
/Users/alvincrespo/Sites/apollo/laravel/laravel.php(138):
Laravel\Response->render() #10
/Users/alvincrespo/Sites/apollo/public/index.php(34):
require('/Users/alvincre...') #11 {main}
I would check that the permissions on:
/Users/alvincrespo/Sites/apollo/storage/views/26bdebca7505781c753aa21663170a1b
Allow your application to write to this directory.
Assuming you are on a linux box you could run ls -l to see what the permissions are, and if it is set to read only, change the permissions with chmod.
As you can see in the very good documentation under install, you have to make the directory storage/views writeable.
http://laravel.com/docs/install#installation
Although it’s an old question but I hope this might help someone, here is what solved the problem for me.
sudo chmod -R 754 storage/
check the permissions of /storage directory in the laravel installation. The views directory must have write permisison for the webserver that is it.

Categories