4

I have just installed a fresh copy of Yii2 advanced and am having trouble getting the style sheets to load. The error seems to be that Yii (or webserver) cannot create path /var/www/frontend/web/assets/1ecfb338/css despite doing so in the same http request that it errors. Even after reinforcing file permissions of 777 from without and outside the VM, Yii doesn't seem to make further attempts to write the stylesheet.

enter image description here

If I just refresh the page loads without error but the stylesheet bootstrap.css has not been created in the directory.

This is most frustrating. Does anyone have any ideas?

If it matters I am running Yii in a Vagrant VM with Virtualbox. Debian is the VM OS and Ubuntu is the host.

Danila Ganchar
  • 10,266
  • 13
  • 49
  • 75
Dubby
  • 2,290
  • 4
  • 27
  • 38

3 Answers3

3

This is quite strange at not experienced this before. I was able to correct this by changing the mode to 777 as the super user from outside the virtual machine. From doing the same thing inside the virtual machine made no difference.

I have worked on many projects before with this kind of setup but not had this before. Software that I'm using that may be responsible is:

Host machine:

  • Ubuntu 14.04
  • Vagrant 1.7.4
  • Virtualbox 4.3.30

Virtual machine:

  • Debian Jessie
  • Nginx 1.6.2
  • PHP 5.6.14

Edit: I found that I had defined the sync folder incorrectly. I had to change to rule this this:

config.vm.synced_folder "./", "/var/www", id: "vagrant-root", :group=>'www-data', :mount_options=>['dmode=775,fmode=775']
Dubby
  • 2,290
  • 4
  • 27
  • 38
  • This answer explains perfectly what's going on and how to fix it. But to be more specific it would be better to let fmode in 664. You can find more info here http://jeremykendall.net/2013/08/09/vagrant-synced-folders-permissions/. But, to sum up, this is the line that fix the issue `config.vm.synced_folder "./", "/var/www", id: "vagrant-root", :group=>'www-data', :mount_options=>['dmode=775,fmode=664']` – Gabo Nov 20 '17 at 03:47
1

You just give permission for particular directory like:

sudo chmod -R 777 /var/www/frontend/web/assets
vishuB
  • 4,173
  • 5
  • 31
  • 49
  • or `sudo chgrp -R www-data /var/www/frontend/web/assets` to just change the group (slightly more secure). – tarleb Dec 10 '15 at 14:13
  • I guess that I'm not explaining this well. The permissions are correct and Yii is creating the directory, but still errors. Maybe the error is occurring because it's trying to create the directory when it already exists (because it just created it). I think I'm going to have to look at the Yii source to understand what is happening. – Dubby Dec 10 '15 at 23:33
0

The solution for me was adding

sed -i 's/www-data/vagrant/g' /etc/apache2/envvars

to the Vagrantfile like written here Vagrant file_put_contents permission denied

user 1007017
  • 391
  • 2
  • 10