apache - Unable to create the cache directory (/vagrant/app/cache/dev) -


i using vagrant tool, below version number of os , tools using.

ubuntu : 13.04

vagrant : vagrant 1.5.1

vm box : 4.2.10_ubuntur84101

below vagrant file content

# -*- mode: ruby -*- # vi: set ft=ruby :  # vagrantfile api/syntax version. don't touch unless know you're doing! vagrantfile_api_version = "2"  vagrant.configure(vagrantfile_api_version) |config|   # vagrant configuration done here. common configuration   # options documented , commented below. complete reference,   # please see online documentation @ vagrantup.com.    # every vagrant virtual environment requires box build off of.   config.vm.box = "hashicorp/precise32"   config.vm.provision :shell, :path => "getmyltd_bootstrap.sh"   config.vm.network :forwarded_port, host: 4567, guest: 80    # url 'config.vm.box' box fetched if   # doesn't exist on user's system.   # config.vm.box_url = "http://domain.com/path/to/above.box"    # create forwarded port mapping allows access specific port   # within machine port on host machine. in example below,   # accessing "localhost:8080" access port 80 on guest machine.   # config.vm.network "forwarded_port", guest: 80, host: 8080    # create private network, allows host-only access machine   # using specific ip.   # config.vm.network "private_network", ip: "192.168.33.10"    # create public network, matched bridged network.   # bridged networks make machine appear physical device on   # network.   # config.vm.network "public_network"    # if true, ssh connections made enable agent forwarding.   # default value: false   # config.ssh.forward_agent = true    # share additional folder guest vm. first argument   # path on host actual folder. second argument   # path on guest mount folder. , optional third   # argument set of non-required options.   # config.vm.synced_folder "../data", "/vagrant_data" )    # provider-specific configuration can fine-tune various   # backing providers vagrant. these expose provider-specific options.   # example virtualbox:   #   # config.vm.provider "virtualbox" |vb|   #   # don't boot headless mode   #   vb.gui = true   #   #   # use vboxmanage customize vm. example change memory:   #   vb.customize ["modifyvm", :id, "--memory", "1024"]   # end   #   # view documentation provider you're using more   # information on available options.    # enable provisioning puppet stand alone.  puppet manifests   # contained in directory path relative vagrantfile.   # need create manifests directory , manifest in   # file hashicorp/precise32.pp in manifests_path directory.   #   # example puppet manifest provision message of day:   #   # # group { "puppet":   # #   ensure => "present",   # # }   # #   # # file { owner => 0, group => 0, mode => 0644 }   # #   # # file { '/etc/motd':   # #   content => "welcome vagrant-built virtual machine!   # #               managed puppet.\n"   # # }   #   # config.vm.provision "puppet" |puppet|   #   puppet.manifests_path = "manifests"   #   puppet.manifest_file  = "site.pp"   # end    # enable provisioning chef solo, specifying cookbooks path, roles   # path, , data_bags path (all relative vagrantfile), , adding   # recipes and/or roles.   #   # config.vm.provision "chef_solo" |chef|   #   chef.cookbooks_path = "../my-recipes/cookbooks"   #   chef.roles_path = "../my-recipes/roles"   #   chef.data_bags_path = "../my-recipes/data_bags"   #   chef.add_recipe "mysql"   #   chef.add_role "web"   #   #   # may specify custom json attributes:   #   chef.json = { :mysql_password => "foo" }   # end    # enable provisioning chef server, specifying chef server url,   # , path validation key (relative vagrantfile).   #   # opscode platform uses https. substitute organization   # orgname in url , validation key.   #   # if have own chef server, use appropriate url, may   # http instead of https depending on configuration. change   # validation key validation.pem.   #   # config.vm.provision "chef_client" |chef|   #   chef.chef_server_url = "https://api.opscode.com/organizations/orgname"   #   chef.validation_key_path = "orgname-validator.pem"   # end   #   # if you're using opscode platform, validator client   # orgname-validator, replacing orgname organization name.   #   # if have own chef server, default validation client name   # chef-validator, unless changed configuration.   #   #   chef.validation_client_name = "orgname-validator" end 

vagrant commands works fine without errors. , enables port number 4567 successfully.

in local machine have virtual host, content of below.

<virtualhost *:80>     serveradmin webmaster@localhost     servername *.testmyltd.com     serveralias admin.testmyltd.com     documentroot /var/www/getmyltd/web     <directory />         options followsymlinks         allowoverride none     </directory>     <directory /var/www/>         options indexes followsymlinks multiviews         allowoverride none         order allow,deny         allow     </directory>         scriptalias /cgi-bin/ /usr/lib/cgi-bin/     <directory "/usr/lib/cgi-bin">         allowoverride none         options +execcgi -multiviews +symlinksifownermatch         order allow,deny         allow     </directory>      errorlog ${apache_log_dir}/error.log      # possible values include: debug, info, notice, warn, error, crit,     # alert, emerg.     loglevel warn      customlog ${apache_log_dir}/access.log combined </virtualhost>  <virtualhost *:4567>         serveradmin webmaster@localhost         servername *.testmyltd.com:4567         serveralias admin.testmyltd.com:4567         documentroot /var/www/getmyltd/web         <directory />                 options followsymlinks                 allowoverride none         </directory>         <directory /var/www/>                 options indexes followsymlinks multiviews                 allowoverride                 order allow,deny                 allow         </directory>          scriptalias /cgi-bin/ /usr/lib/cgi-bin/         <directory "/usr/lib/cgi-bin">                 allowoverride none                 options +execcgi -multiviews +symlinksifownermatch                 order allow,deny                 allow         </directory>          errorlog ${apache_log_dir}/error.log          # possible values include: debug, info, notice, warn, error, crit,         # alert, emerg.         loglevel warn          customlog ${apache_log_dir}/access.log combined </virtualhost> 

hitting urls http://admin.testmyltd.com:4567/app_dev.php , http://admin.testmyltd.com/ loads project directory structure in browser,

enter image description here

trying run project through port 4567 (http://admin.testmyltd.com:4567/app_dev.php) throws run time exception :

runtimeexception: failed write cache file "/vagrant/app/cache/dev/classes.php". 

full permission set "vagrant" directory in guest os , project directory in host os along files , sub directories inside that.

can tell me things went wrong ?

thanks in advance.

as per discussion had, can problem permission user.

following scenario.

your host os running under user pc-16, , /var/www directory having ownership of pc-16 user itself. default under ubuntu/debian apache running www-data user mode. first change run pc-16 (i'l tell later why need that)

in host os:

changing user of apache under host os user.

$sudo vi /etc/apache2/envvars 

and change

export apache_run_user=www-data export apache_run_group=www-data 

to,

export apache_run_user=pc-16 export apache_run_group=pc-16 

and restart apache2,

$sudo service apache2 restart 

it may give error regarding /var/lock/apache2 directory, in case change ownership of /var/lock/apache2 pc-16 user.

$sudo down pc-16:pc-16 /var/lock/apache2 

and restart apache2,

$sudo service apache2 restart 

also make sure /var/www/virtualhost-directory/app/ writable. if it's not, change permission host-os terminal.

$sudo chmod 777 /var/www/virtualhost-directory/app 

running $vagrant up run virtualbox guest machine pc-16 user mode, , have privileges of user pc-16

the problem is, apache in host-os running under www-data user mode, , web-application trying create directory/files under /var/www/, have changed work pc-16 user.

now, in vagrant box, run user vagrant , shared directory of host come vagrant user ownership only, (with few limitations can't change ownership of shared files guest os). so, need change apache user of guest os vagrant.

follow same steps described host-os apache.

in guest os:

changing user of apache under guest os vagrant.

$sudo vi /etc/apache2/envvars 

and change

export apache_run_user=www-data export apache_run_group=www-data 

to,

export apache_run_user=vagrant export apache_run_group=vagrant 

and restart apache2,

$sudo service apache2 restart 

in case locking directory ownership error.

$sudo chown vagrant:vagrant /var/lock/apache2 

and restart apache2,

$sudo service apache2 restart 

now should able access web-application host-os like,

http://admin.testmyltd.com/    <-- run project local directory  http://admin.testmyltd.com:4567/app_dev.php  <-- run same project vagrant box (shared project directory) 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

inno setup - TLabel or TNewStaticText - change .Font.Style on Focus like Cursor changes with .Cursor -