dsomel21
dsomel21

Reputation: 626

Frustration Installing Laravel on Ubuntu

Now I remember why I never got into PHP. It's such a pain to set up. I spent a couple hours today trying to complete a coding challenge which required me to install Composer, Vagrant, VirtualBox and Laravel.

Somewhere along the line I think my permissions or something changed, because whenever I try to install Laravel...

composer global require "laravel/installer"

I get...

Changed current directory to /home/dilraj/.composer

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


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--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] [--apcu-autoloader] [--] [<packages>]...

I am not sure why I am getting this, perhaps it is because I have already done it, but regardless, when I try to create an executable command I am not seeing any results.

I edited the .bashrc file, as such...

export PATH="$PATH:$HOME/.config/composer/vendor/bin

source ~/.bashrc

I am not going to lie, I don't what this is even doing. I just want to make it so I can type 'laravel' and then start doing stuff, kinda like in npm.

Here are other things I tried but succeeded without any luck :(

export PATH="$PATH:$HOME/.composer/vendor/bin"

export PATH="$PATH:$HOME/.config/composer/vendor/bin"

alias laravel='~/.config/composer/vendor/bin/laravel'

Upvotes: 1

Views: 503

Answers (2)

omdjin
omdjin

Reputation: 389

seems like you have install composer as root. You can try to install laravel without Laravel Installer by run :

composer create-project --prefer-dist laravel/laravel projectfolder

It its not working, try using sudo command :

sudo composer create-project --prefer-dist laravel/laravel projectfolder

Upvotes: 0

Niraj Shah
Niraj Shah

Reputation: 15457

You don't you address the issue noted in the error, primarly Permission denied. Running chmod 755 .composer should be enough to give you permission to edit the file.

If that doesn't work, add sudo in front of it to update it using root account.

Upvotes: 1

Related Questions