Unable to create the cache directory (/cache/)

Asked

Viewed 409 times

-2

After I installed Fedora, while trying to log into my application with Symfony2, I cannot fix this error:

Runtimeexception in bootstrap.php.cache line 2671: Unable to create the cache directory (/cache/)

I’ve tried several alternatives, including those on the official website, but nothing.

I installed PHP from the terminal, without Apache because I use the PHP build-in server.

2 answers

1

You need to delete the contents of your folder cache (and also the folder logs, if necessary) and then reconfigure the folder permissions.

For systems that support chmod +a:

$ rm -rf app/cache/*
$ rm -rf app/logs/*
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
$ sudo chmod +a "$HTTPDUSER allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
$ sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs

For systems that do not support chmod +a:

$ rm -rf app/cache/*
$ rm -rf app/logs/*
$ HTTPDUSER=`ps axo user,comm | grep -E '[a]pache|[h]ttpd|[_]www|[
w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`
$ sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
$ sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs

0

Guy has several things that can generate this error. Here are some possible solutions.

1- It can be the permission of the cache and log folder inside the symfony app folder

2- You can try updating the files by Composer (php Composer.phar install or update), it all depends on how your project was mounted.

Most likely you use Composer to update, this error has occurred to me and I was able to resolve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.