Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php oauth-private.key不存在或不可读_Php_Laravel_Laravel 5_Oauth 2.0_Laravel Passport - Fatal编程技术网

Php oauth-private.key不存在或不可读

Php oauth-private.key不存在或不可读,php,laravel,laravel-5,oauth-2.0,laravel-passport,Php,Laravel,Laravel 5,Oauth 2.0,Laravel Passport,因此,我从Bitbucket导入了另一个项目,并尝试使用php artisan serve启动它,我总是遇到以下错误: [LogicException] Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" does not exist or is not re

因此,我从Bitbucket导入了另一个项目,并尝试使用
php artisan serve
启动它,我总是遇到以下错误:

[LogicException]                                                                   
  Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" does not   
  exist or is not readable                                                           
当我自己做一个项目时,我没有得到这个错误,我不能运行任何其他命令。我尝试了“php artisan key:generate”,得到了完全相同的错误

我尝试了:
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

有人知道怎么修吗?谢谢

我认为这是因为Laravel Passport,您应该尝试以下命令:

php artisan passport:install
此命令将创建生成安全密钥所需的加密密钥 访问令牌。此外,该命令将创建“个人访问” 和“密码授予”客户端,用于生成访问权限 代币

来源:

我找到了解决方案 解决方案: 在config/app.php中,我必须对以下几行进行注释:

/*Laravel\Passport\PassportServiceProvider::class,
App\Providers\CodeGrantProvider::class,
Spatie\Permission\PermissionServiceProvider::class,*/
然后需要再次迁移整个数据库, 然后取消对此行的注释:

Laravel\Passport\PassportServiceProvider::class,
然后运行
php artisan passport:install
我的应用程序密钥不起作用,因此我必须执行以下操作:

php artisan config:clear
php artisan key:generate
php artisan config:clear
而我能做的就是
php工匠服务

谢谢

执行此命令

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

更新composer时我也遇到了同样的问题。我使用php artisan passport:keys再次生成了密钥,它解决了问题在文件的特定位置有密钥之前不要执行这一行

在AuthServiceProvider.php中

//Passport::loadKeysFrom('/secret-keys/oauth')

步骤1:

仅当中不存在
oauth private.key
oauth public.key
时运行 存储文件夹,否则跳过第一步

步骤2:

清除配置并生成密钥

步骤3:

这样更改权限和所有者


由于
/storage/*.key
位于
.gitignore
中,因此如果您拉取项目,运行
php artisan passport:keys可能会丢失密钥,它将为您生成新密钥。

我已删除此位:
passport::loadKeysFrom(\uu DIR\uu./../secrets/oauth')
App\Providers\AuthServiceProvider
开始,它解决了这个问题

  • 运行:php artisan passport:安装。 如果收到类似“加密密钥已存在。请使用--force选项覆盖它们”的消息 然后跑
  • 运行:php artisan配置:清除
  • 运行:php artisan键:生成。 最后
  • 运行:php artisan配置:清除

  • 你能看到上面提到的路径中的文件吗?如果可以,请检查权限
    /storage/oauth private.key
    否。它不在那里。但这在其他文件中不是问题。谢谢!我只是插入您的代码php artisan passport:install,它在部署it服务器时非常有用,不想重新安装passportphp artisan passport:install不会重新安装passport。。。如果已经安装,它将跳过安装并生成密钥…非常感谢分享
    php artisan passport:install
    
     php artisan config:clear
     php artisan key:generate
     php artisan config:clear
    
    sudo chown www-data:www-data storage/oauth-*.key
    sudo chmod 600 storage/oauth-*.key
    
    /**
     * Register any authentication / authorization services.
     *
     * @return void
     */
    public function boot()
    {
        $this->registerPolicies();
    
        Passport::routes();
    
        Passport::loadKeysFrom(__DIR__.'/../secrets/oauth');
    }