php – Composer:file_put_contents(./ composer.json):无法打开流:权限被拒绝

我正在尝试将Prestissimo安装到Ubuntu 16.04服务器,但这会导致错误:

$ composer global require "hirak/prestissimo:^0.3"
Changed current directory to /home/kramer65/.composer


  [ErrorException]
  file_put_contents(./composer.json): failed to open stream: Permission denied


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--] [<packages>]...

我以用户kramer65身份登录,所以我不知道为什么它无法写入我的主文件夹。我对拒绝许可的正常反应是使用sudo,但作曲家总是说:

Do not run Composer as root/super user! See 07001 for details

知道怎么解决这个问题吗?

最佳答案
我有这个问题来安装laravel / lumen。

我可以使用以下命令解决:

$ sudo chown -R $USER ~/.composer/

转载注明原文:php – Composer:file_put_contents(./ composer.json):无法打开流:权限被拒绝 - 代码日志