Reputation: 125
I am trying out Laravel and after installation I get the following when attempting to start a new application:
using code: laravel new blog
I get:
PHP Warning: file_put_contents(/var/www/html/laravel_d4381b5ce250405766ef8b9fa784b256.zip): failed to open stream: Permission denied in /home/ren/.composer/vendor/laravel/installer/src/NewCommand.php on line 81
PHP Warning: ZipArchive::extractTo(): Permission denied in /home/ren/.composer/vendor/laravel/installer/src/NewCommand.php on line 99
PHP Warning: ZipArchive::close(): Invalid or unitialized Zip object in /home/ren/.composer/vendor/laravel/installer/src/NewCommand.php on line 101
Application ready! Build something amazing.
Upvotes: 9
Views: 8052
Reputation: 44586
It seems the user you're running the command with, doesn't have the necessary permissions to write to /var/www/html/
. Try changing the permissions or owner of that directory. Try:
sudo chown $USER /var/www/html
The $USER
variable contains the logged in username (in your case ren
), so it will make your user the owner of that directory. Then run the installation command:
laravel new blog
Upvotes: 27
Reputation: 185
As a noob, it took me a few good painstakingly hours to figure this out. As far as my understanding goes, you'll need to initiate the new project with laravel new <project>
in a 777 directory. So you'd go like:
### make directory and grant full permissions
sudo mkdir /var/www/laravel
sudo chmod -R 777 /var/www/laravel/
cd /var/www/laravel/
### run laravel installer
laravel new web-project
### move your project in www root
sudo mv web-project /var/www/
The last bit where you move the directory is optional and you may leave it there or move it to anywhere your vhost might be set up.
Personal note: I was actually hoping setting up a new Laravel app to be easier than this. I'm confident however it will get easier with practice :)
Upvotes: -1