Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Laraveldeep's avatar

Getting Permission Denied Error on 'laravel new blog' inside Vagrant

Hi,

I am an absolute Laravel beginner. Just finished installing homestead. "vagrant up" and "vagrant ssh" is fine. Now I am trying to create a new project inside "Code" using "laravel new blog" but I am getting permission denied error. Was expecting that folder to be created "Code/blog". I have tried "chmod 777 Code" but still getting that error. However I can create projects on vagrant home folder.

These Details might help:

Exact Error Message:

Crafting application...
PHP Warning:  file_put_contents(/home/vagrant/Code/laravel_438edf6e30add49004702249a44cc69b.zip): failed to open stream: Permission denied in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 122

Warning: file_put_contents(/home/vagrant/Code/laravel_438edf6e30add49004702249a44cc69b.zip): failed to open stream: Permission denied in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 122
PHP Warning:  ZipArchive::extractTo(): Permission denied in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 140

Warning: ZipArchive::extractTo(): Permission denied in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 140
PHP Warning:  ZipArchive::close(): Invalid or uninitialized Zip object in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 142

Warning: ZipArchive::close(): Invalid or uninitialized Zip object in /home/vagrant/.composer/vendor/laravel/installer/src/NewCommand.php on line 142
Composer could not find a composer.json file in /home/vagrant/Code
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Application ready! Build something amazing.

My "Homestead.yaml" file:

ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: D:/LARAVEL_PROJECTS
      to: /home/vagrant/Code

sites:
    - map: blog.dev
      to: /home/vagrant/Code/blog/public

databases:
    - homestead

Need some pointers

My OS and other info

Windows 8.1
VirtualBox 5.1.2
Vagrant 1.8.5

Thanks in advance!

0 likes
3 replies
Laraveldeep's avatar

Tried few thing and found out that I really can't create anything inside "Code" with current credentials.

Did this and worked:

$ cd Code
$ sudo laravel new blog

I thought we are connecting to ssh with a root permission. Why do we need to sudo?

Also I got this warning few times during this process.

Do not run Composer as root/super user! See https://getcomposer.org/root for details

Is it ok what i did? my project created as expected (except few warnings).

Should I continue from there? Some suggestions really appreciated.

Thanks!

Kennyendowed's avatar

this is wat u should do

sudo chown $USER /var/www/html $USER is ur username for ur system so put yours they

automica's avatar

@kennyendowed the point of homestead is that it syncs your filesystem with the vm.

You shouldn't have to make file changes directly inside the vm, rather just do it locally.

install your Laravel project locally and it'll copy map those files to the VM

exactly what its doing here

folders:
    - map: D:/LARAVEL_PROJECTS
      to: /home/vagrant/Code

sites:
    - map: blog.dev
      to: /home/vagrant/Code/blog/public

Please or to participate in this conversation.