I tried to make a yii project for testing by executing
/var/www/html/yii/framework/yiic webapp demo
and when I go to localhost/demo I get en error:
Application runtime path "/var/www/html/demo/protected/runtime" is not valid.
Please make sure it is a directory writable by the Web server process.
At first I thought that it really isn't writable so I did:
chmod 777 /var/www/html/demo/protected/runtime
didn't work so as the last idea I executed:
chmod 777 -R /var/www/html/demo/
and I still get the same exception. Any ideas on what might be wrong?
---EDIT---
FFS this drives me nuts
drwxrwxrwx. 4 apache apache 4096 Jun 5 00:06 commands
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 components
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 config
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 controllers
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 data
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 extensions
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 messages
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 migrations
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 models
drwxrwxrwx. 3 apache apache 4096 Jun 5 00:06 runtime
drwxrwxrwx. 7 apache apache 4096 Jun 5 00:06 tests
drwxrwxrwx. 5 apache apache 4096 Jun 5 00:06 views
-rwxrwxrwx. 1 apache apache 71 Jun 5 00:02 yiic
-rwxrwxrwx. 1 apache apache 380 Jun 5 00:02 yiic.bat
-rwxrwxrwx. 1 apache apache 178 Jun 5 00:02 yiic.php
and I still can't write files from within php script
That should work... so maybe also try setting your Apache user (usually 'www-data') as the owner of /runtime
? Something like:
chown -R www-data:www-data /var/www/html/demo/protected/runtime
Could be an Apache umask
issue also. Check out the Yii forum, which has helpful posts like this one: http://www.yiiframework.com/forum/index.php?/topic/19400-question-about-directoryfile-permissions/
You should NOT have to set your whole project to 777, that is very insecure. I think /assets
and /protected/runtime
are the only directories that need write permissions (775).
Looks like you might have SELinux turned on, which enforces it's own security policies and can be a real pain for web apps and very annoying when it ends up resulting in errors like this. Whenever you have funky permissions problems, it's a good idea to check if you have it set:
/usr/sbin/getenforce
(or similar, depending on what system you are on).
See: http://www.crypt.gen.nz/selinux/disable_selinux.html for a good overview and how to turn it off (again, the details may vary depending on your OS/kernel version). If it's a test machine not publicly accessible, you can pretty safely turn it off, otherwise, you should read the site above to understand what it does. Most Linux package managers can install files to help you manage the policies for specific apps. On RH/CentOS, you can also use /usr/bin/system-config-securitylevel-tui
to turn it on/off.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With