Laravel shows 'Permission denied' after local package added - php

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

Related

Magento 2.4.4 - Error Class does not exist during setup:di:compile

I am trying to run setup:di:compile on Magento 2.4.4, but I am getting a strange error and have no idea where to look or how to debug this.
Here is the code from the error log:
Proxies code generation... 1/9 [===>------------------------] 11% 1 sec 139.0 MiB Repositories code generation... 1/9 [===>------------------------] 11% 1 sec 139.0 MiBClass "Magento\Framework\DB\DataConverter\SerializedToJson" not found #0 /public_html/vendor/composer/ClassLoader.php(444): include() #1 /public_html/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile() #2 [internal function]: Composer\Autoload\ClassLoader->loadClass() #3 /public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(134): class_exists() #4 /public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(117): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->includeClass() #5 /public_html/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassesScanner.php(87): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->extract() #6 /public_html/setup/src/Magento/Setup/Module/Di/App/Task/Operation/RepositoryGenerator.php(61): Magento\Setup\Module\Di\Code\Reader\ClassesScanner->getList() #7 /public_html/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php(56): Magento\Setup\Module\Di\App\Task\Operation\RepositoryGenerator->doOperation() #8 /public_html/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php(216): Magento\Setup\Module\Di\App\Task\Manager->process() #9 /public_html/vendor/symfony/console/Command/Command.php(255): Magento\Setup\Console\Command\DiCompileCommand->execute() #10 /public_html/vendor/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run() #11 /public_html/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand() #12 /public_html/vendor/magento/framework/Console/Cli.php(115): Symfony\Component\Console\Application->doRun() #13 /public_html/vendor/symfony/console/Application.php(149): Magento\Framework\Console\Cli->doRun() #14 /public_html/bin/magento(23): Symfony\Component\Console\Application->run() #15 {main}
Tried to redeploy static files and so on, but the issue still persists.
Thanks very much for your help!
I have tried:
clearing generated folder
deploying static content
clearing cache
reindexing
What you can simply do is:
Remove the vendor directory and launch the terminal again and execute the command
composer install
to regenerate all the Magento standard codes. You can check your vendor folder to ensure all dependencies are installed and run the compilation command later to load the dependencies.
Please make sure to backup the previous folder as well for safer side.

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

Laravel 5: unstable display errors

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

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