laravel oauth-private.key 不存在或不可读
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42795011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
oauth-private.key does not exist or is not readable
提问by O'Niel
So, I imported another project from Bitbucket and tried to launch it using php artisan serve
, I always get this error:
因此,我从 Bitbucket 导入了另一个项目并尝试使用 启动它php artisan serve
,我总是收到此错误:
[LogicException]
Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" does not
exist or is not readable
I don't get this error when I make a project myself, I can't run any other command. I tried 'php artisan key:generate', and got the exact same error.
我自己制作项目时没有收到此错误,我无法运行任何其他命令。我试过'php artisan key:generate',得到了完全相同的错误。
I tried: composer update
, and got this:
我试过:composer update
,得到了这个:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating spatie/laravel-permission (1.11.1 => 1.12.0) Downloading: 100%
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
[LogicException]
Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" doe
s not exist or is not readable
Script php artisan optimize handling the post-update-cmd event returned with error code 1
Anyone knows how to fix it? Thanks!
有谁知道如何修复它?谢谢!
采纳答案by O'Niel
I found the solution Solution:In config/app.php I had to comment these lines:
我找到了解决方案解决 方案:在 config/app.php 我必须注释这些行:
/*Laravel\Passport\PassportServiceProvider::class,
App\Providers\CodeGrantProvider::class,
Spatie\Permission\PermissionServiceProvider::class,*/
Than you need to migrate the whole database again, than uncomment this line:
比你需要再次迁移整个数据库,而不是取消注释这一行:
Laravel\Passport\PassportServiceProvider::class,
And run php artisan passport:install
my application keys weren't working so I had to do:
并运行php artisan passport:install
我的应用程序密钥不起作用所以我不得不这样做:
php artisan config:clear
php artisan key:generate
php artisan config:clear
And than I could do php artisan serve
而且比我能做的 php artisan serve
Thanks!
谢谢!
回答by Hammerbot
I think that this is due to Laravel Passport, you should try the following command:
我认为这是由于 Laravel Passport,您应该尝试以下命令:
php artisan passport:install
This command will create the encryption keys needed to generate secure access tokens. In addition, the command will create "personal access" and "password grant" clients which will be used to generate access tokens
此命令将创建生成安全访问令牌所需的加密密钥。此外,该命令将创建“个人访问”和“密码授予”客户端,用于生成访问令牌
回答by Sandesh Chaudhari
I had the same problem when I updated the composer.I generated the keys again using php artisan passport:keysand it solved the problem
我更新作曲家时遇到了同样的问题。我再次使用php artisanpassport:keys生成了密钥,它解决了问题
回答by shivanikoko
Since /storage/*.key
is in .gitignore
so if you pull the project, that might be missing the key by running php artisan passport:keys
will generate new keys for you.
既然如此/storage/*.key
,.gitignore
如果您拉动项目,那么运行php artisan passport:keys
时可能会丢失密钥,将为您生成新密钥。
回答by Ahmed Safadi
do this commands
做这个命令
sudo chown www-data:www-data storage/oauth-*.key
php artisan passport:install
php artisan config:clear
php artisan key:generate
php artisan config:clear
回答by Jignesh Joisar
Step 1:
第1步:
Only Run if
oauth-private.key
andoauth-public.key
not exists in storage folder otherwise skip first step..
仅当存储文件夹中不存在 时才运行
oauth-private.key
,否则跳过第一步..oauth-public.key
php artisan passport:install
Step 2:
第2步:
Clear configration and generate key
清除配置并生成密钥
php artisan config:clear
php artisan key:generate
php artisan config:clear
Step 3:
第 3 步:
Change permission and owner like that:
像这样更改权限和所有者:
sudo chown www-data:www-data storage/oauth-*.key
sudo chmod 600 storage/oauth-*.key
回答by amine ghandi
Dont do this line untill you have keys in a specific location for the file
在文件的特定位置有密钥之前不要执行此行
in AuthServiceProvider.php
在 AuthServiceProvider.php 中
//Passport::loadKeysFrom('/secret-keys/oauth');
//Passport::loadKeysFrom('/secret-keys/oauth');