10

Trying to get a Symfony2 project up and running with a vagrant VM. I've seen a zillion articles on this, but getting the cache directory permissioned correctly is proving to be excruciatingly painful.

In my Vagrantfile:

config.vm.share_folder("src", "/var/www", "../www")

My VM's fstab file:

proc            /proc           proc    nodev,noexec,nosuid 0       0
/dev/mapper/ubuntu--1110-root /               ext4    acl,errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=4ed7eaaf-6f42-48ba-b5ed-f0c1df9add38 /boot           ext2    defaults        0       2
/dev/mapper/ubuntu--1110-swap_1 none            swap    sw              0       0

The acl package has been installed on the VM.

When I run the following in /var/www as per the Symfony2 install directions:

 sudo setfacl -R -m u:apache:rwx -m u:username:rwx app/cache app/logs

I get:

Operation not supported

I can run the command on any other directory or file on the FS (outside of the shared directory) and the command works. What gives?

kenorb
  • 5,943
  • 1
  • 44
  • 53
Josh Nankin
  • 722
  • 11
  • 27
  • This didn't solve the actual problem, but executed this work around for now: http://stackoverflow.com/questions/7357120/changing-cache-dir-and-log-dir-with-symfony2 – Josh Nankin Apr 27 '12 at 17:26

2 Answers2

6

To bypass all the permission problems with Symfony2 and Vagrant, the easiest solution is to change the user and group running apache to vagrant. To do so, edit the file /etc/apache2/envvars and replace lines 16 and 17 with these: export APACHE_RUN_USER=vagrant export APACHE_RUN_GROUP=vagrant Note that these instructions are for apache 2.2 on Ubuntu, refer on your apache and OS version to do so.

If you don't want to change apache user and group, you could also mount a ramdisk and put your symfony project on it. Then vagrant can modify the permissions on this disk. See this link for instructions on how to mount a ramdisk.

jfcartier
  • 161
  • 1
  • 3
3

A better solution is using Attribute Overriding. See Opscode Wiki.

For example in a roles defintion:

override_attributes({
    "apache" => {
      "user" => "vagrant",
      "group" => "vagrant"
    }
})

I had the same problem with Typo3 in a shared Folder, failing to create temporary files.

kenorb
  • 5,943
  • 1
  • 44
  • 53