I am trying to deploy yii-2 application on digital ocean droplet(CentOS 7) with Nginx web server. I have set the www folder perimission to:
chmod -R 775 /var/www
and ownership is tested with www/apache user. But still getting permission denied to create cache folder:
Exception – yiibaseException
Failed to create directory "/var/www/html/frontend/runtime/cache": mkdir(): Permission denied
Caused by: yiibaseErrorException
mkdir(): Permission denied
in /var/www/html/vendor/yiisoft/yii2/helpers/BaseFileHelper.php at line 628
Please guide me, am i doing something wrong ?
2
Answers
You need to let selinux know what directories you’re going to allow the http process to write to. think of it as another set of permissions.
use chcon to set or change these permissions
here’s my quick list of dirs a typical yii app needs to write to
note that the wildcard (
*
) in the above paths applies to all directories in wwwproject specific paths that need write access (file/image upload folders) need to be applied individually
you could also read more about contexts here
if it’s a new setup, you will probably need to set the following flags for things to work properly
if all of that just isn’t your cup of tea you ca enable permissive mode
I think you should give:
sudo chmod -R 777 /var/www/html/frontend/runtime