Reputation: 1725
I'm trying to set up an environment in my Virtual Machine which is an Ubuntu 15.10. I've followed a tutorial with these steps:
curl -sS https://getcomposer.org/installer | php
sudo mv ~/composer.phar /usr/local/bin/composer
composer global require "laravel/installer"
Then I do:
sudo nano ~/.profile
And I add this to end of file:
PATH="$PATH:~/.composer/vendor/bin"
Finally:
composer global update
After these steps, I try:
laravel new project
And get this error:
PHP Warning: file_put_contents(/var/www/html/laravel_62a1f2f16d54929f3367e5f18f937a47.zip): failed to open stream: Permission denied in /home/alavaros/.composer/vendor/laravel/installer/src/NewCommand.php on line 114
PHP Warning: ZipArchive::extractTo(): Permission denied in /home/alavaros/.composer/vendor/laravel/installer/src/NewCommand.php on line 132
PHP Warning: ZipArchive::close(): Invalid or uninitialized Zip object in /home/alavaros/.composer/vendor/laravel/installer/src/NewCommand.php on line 134
Composer could not find a composer.json file in /var/www/html
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Upvotes: 2
Views: 26947
Reputation: 2744
It looks like you have a permission issue.
What is the output of ls -l /var/www
?
You should see that you have write permission (w
) for public or that you are in the group listed.
For example, you might see
drwxr-xr-x 3 root root 4096 Jul 4 2015 .
Which means you would have issues writing to /var/www
without acting as root
.
Simply running sudo laravel new project
might fix your current problem, but may incur you having to use sudo
whenever you want to work.
A better solution would be to give yourself access to this directory:
sudo chmod o+w /var/www/
Running this command will give all (other) users (including you) on this machine write access to /var/www
Upvotes: 2