yii php framework “Application runtime path is not

2019-03-15 13:12发布

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

标签: php yii
9条回答
Root(大扎)
2楼-- · 2019-03-15 13:39

Try to upload 'runtime' folder again on your server, that works for me.

查看更多
Juvenile、少年°
3楼-- · 2019-03-15 13:41

You have entered a wrong syntax for the chmod command. Try this:

sudo chmod -R 777 ./var/www/*

Enter a password when you will be prompt.

Important notice:

The asterisk at the end of command line is very important. It means all files in the current directory.

查看更多
beautiful°
4楼-- · 2019-03-15 13:41

Changed access of the entire folder of the site by using the following command

sudo chmod -R 777 'name of your website folder'

This will solve the issue.

查看更多
再贱就再见
5楼-- · 2019-03-15 13:44

you must config with semanage like this which allow php-fpm write access to directory

# semanage fcontext -a -t httpd_sys_rw_content_t 'YOUR_PATH_HERE'
# restorecon -v 'YOUR_PATH_HERE'
查看更多
趁早两清
6楼-- · 2019-03-15 13:47

If u r sure file permissions set correctly for the folder and still u getting the error, disabling SElinux or add an exception for SElinux is working if u r using CentOS. edit /etc/selinux/config file for disable SElinux or run this command for add an exception

sudo chcon -t httpd_sys_rw_content_t /path/to/ur/annoying/folder -R

查看更多
Explosion°爆炸
7楼-- · 2019-03-15 13:48

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).

查看更多
登录 后发表回答