You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

调用Laravel API时触发CryptKey.php逻辑异常的问题求助

Hey there, let's tackle this OAuth key issue you're facing. The error clearly points to a missing/unreadable key file at file:///home/brulltaxiapp/public_html/storage/oauth-public.key, and since you mentioned installing as root and moving the public folder to public_html, this is almost certainly a combination of missing key files, permission problems, or incorrect path configuration. Here's how to fix it step by step:

1. First, check if the OAuth key files exist

Head over to the path mentioned in the error (/home/brulltaxiapp/public_html/storage/) and see if oauth-public.key and oauth-private.key are present.

  • If they're not there, generate them by running this command from your Laravel project root (which should be /home/brulltaxiapp/public_html/):
    php artisan passport:keys
    
    This will create the required key files directly in the storage directory.

2. Fix file permissions (critical for root-installed setups)

Since you installed Laravel as root, the key files and storage directory are likely owned by the root user—your web server (Apache/Nginx, usually running as www-data or apache) can't access these files by default. Fix this with:

# Navigate to your project root
cd /home/brulltaxiapp/public_html/

# Change ownership of the storage directory to your web server user
chown -R www-data:www-data storage/

# Set proper permissions to ensure read access
chmod -R 755 storage/

(If your web server uses a different user than www-data—like httpd on CentOS—replace it with that user.)

3. Verify Passport's key path configuration

It's possible your Passport config is pointing to the wrong path (especially since you moved the public folder). Open config/passport.php and check these lines:

'public_key' => storage_path('oauth-public.key'),
'private_key' => storage_path('oauth-private.key'),

Make sure they're using storage_path() (which points to your project's storage folder) instead of public_path() (which would incorrectly point to public_html). If you adjusted these paths, clear the config cache to apply changes:

php artisan config:clear

4. Quick note on project structure

Putting your entire Laravel project (including storage and config) inside public_html is a security risk, since public_html is web-accessible. Ideally, you should have public_html act as your Laravel public folder, with the rest of the project (app, storage, config, etc.) in a parent directory outside public_html. But if you're stuck with this setup for now, the steps above should resolve the error.

After following these steps, try your Postman request again—it should work without the LogicException.

内容的提问来源于stack exchange,提问作者irfan majeed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 04:27:31