简体   繁体   中英

Laravel 5.1 installing from composer issue - Permission Denied

I can install laravel 5.0 with composer without any issue. But when I try to install laravel 5.1, I get permission denied.

This is what I get if I run:

composer create-project laravel/laravel MyProjectName

Installing laravel/laravel (v5.1.4)
  - Installing laravel/laravel (v5.1.4)
    Loading from cache

Created project in schoollege
> php -r "copy('.env.example', '.env');"
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing vlucas/phpdotenv (v1.1.1)
    Loading from cache

  - Installing symfony/var-dumper (v2.7.3)
    Loading from cache

  - Installing symfony/translation (v2.7.3)
    Loading from cache

  - Installing symfony/routing (v2.7.3)
    Loading from cache

  - Installing symfony/process (v2.7.3)
    Loading from cache

  - Installing psr/log (1.0.0)
    Loading from cache

  - Installing symfony/debug (v2.7.3)
    Loading from cache

  - Installing symfony/http-foundation (v2.7.3)
    Loading from cache

  - Installing symfony/event-dispatcher (v2.7.3)
    Loading from cache

  - Installing symfony/http-kernel (v2.7.3)
    Loading from cache

  - Installing symfony/finder (v2.7.3)
    Loading from cache

  - Installing symfony/dom-crawler (v2.7.3)
    Downloading: 100%         



  [ErrorException]                                                                                                                                
  copy(/home/myusername/.composer/cache/files/symfony/dom-crawler/9dabece63182e95c42b06967a0d929a5df78bc35.zip): failed to open stream: Permission denied                                                                                                                                        



create-project [-s|--stability="..."] [--prefer-source] [--prefer-dist] [--repository-url="..."] [--dev] [--no-dev] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--keep-vcs] [--no-install] [--ignore-platform-reqs] [package] [directory] [version]

I am doing this inside /var/www/html folder. The /var/www folder is already listed in www-data group and www-data has the permission drwxrwxr-x

Solutions I tried but none of the them worked:

  • composer clearcache
  • composer create-project laravel/laravel MyProjectName 5.1
  • composer self-update

What could be the possible issue ?

PS: I am using LAMP on Ubuntu 14.04 LTS x64 bit architecture.

When you run artisan command, you are not running as www-data user, but as your user instead. If your user is not root, you should execute this command as sudo , or with su www-data , OR (better yet) you can add your username to www-data group, like this:

sudo useradd -g www-data youruser

Hope it helps. ;)

My proble was similar like you ...... copy(/home/user_name/.composer/cache/files/vlucas/phpdotenv/ failed to open stream: Permission denied in laravel

I think we faced this problem for directory permission of /home/user_name/.composer

After running below command, I able to create my project successfully ..

sudo chown -R user_name /home/user_name/.composer/

I have faced the same problem on mac, run the following commands:

  1. sudo composer clearcache
  2. composer dump-autoload
  3. run all other commands you want

Since composer was already halfway through at the point of 'permission denied', you will need to clear cache before following Rafael's instruction:

php artisan cache:clear 
composer dump-autoload

(from https://stackoverflow.com/a/24369509/1627732 )

and then do:

sudo useradd -g www-data yourusername

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM