Yii CAssetManager.basePath“/“资产”;这是无效的。请确保目录存在并且可由Web服务器进程写入。?
当我在服务器上运行YII项目时,我遇到了这个错误Yii CAssetManager.basePath“/“资产”;这是无效的。请确保目录存在并且可由Web服务器进程写入。?,yii,Yii,当我在服务器上运行YII项目时,我遇到了这个错误 CException CAssetManager.basePath "/var/www/html/v2/assets" is invalid. Please make sure the directory exists and is writable by the Web server process. /var/www/html/v2/yii/framework/web/CAssetManager.php(116) 104 }
CException
CAssetManager.basePath "/var/www/html/v2/assets" is invalid. Please make sure the directory exists and is writable by the Web server process.
/var/www/html/v2/yii/framework/web/CAssetManager.php(116)
104 }
105
106 /**
107 * Sets the root directory storing published asset files.
108 * @param string $value the root directory storing published asset files
109 * @throws CException if the base path is invalid
110 */
111 public function setBasePath($value)
112 {
113 if(($basePath=realpath($value))!==false && is_dir($basePath) && is_writable($basePath))
114 $this->_basePath=$basePath;
115 else
116 throw new CException(Yii::t('yii','CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and is writable by the Web server process.',
117 array('{path}'=>$value)));
118 }
119
120 /**
121 * @return string the base url that the published asset files can be accessed.
122 * Note, the ending slashes are stripped off. Defaults to '/AppBaseUrl/assets'.
123 */
124 public function getBaseUrl()
125 {
126 if($this->_baseUrl===null)
127 {
128 $request=Yii::app()->getRequest();
我不知道,怎么解决?请解释一下解决方法
这是我的项目结构
assets
protected <-- Yii app
js
css
yii
资产
受保护的资产文件夹应可由web服务器进程写入。如果在默认情况下配置了apache,则通常是www数据。
您可以使用“+w”权限修改将用户添加到文件夹组
或者,只需将权限修改为777 as assets文件夹将只包含您的js和css文件,这些文件无论如何都将公开给公众
从根目录
chmod 777 -R ./assets
对于runtime和data/auth.php,您也将面临同样的问题(如果应用程序配置为使用Yii auth角色),您也可以在那里进行类似的适当修改
更新::如果设置了安全模式标志,则需要对PHP<5.4进行其他设置(这在5.4中被降低),请参阅如何在PHP.ini文件中配置安全模式设置。您可以完全关闭标志,也可以排除有问题的目录。(如果已添加www数据(web进程),则不需要此步骤)gid将自动匹配到您的组。如果/var/www/html/v2/assets
存在,则Web服务器用户无法写入。如果/var/www/html/v2/assets
不是项目的assets
目录,则您的应用程序配置不正确。我现在应该做什么?如果目录存在,您应该授予wri权限对web服务器进程的权限,如Manquer编写的。还必须创建受保护/运行时
目录并可写入。很巧合,我有这个确切的错误,而您的答案是最近的。更改权限有效,但导致另一个错误:copy()[]:安全模式限制生效。uid/gid为219804/219804的脚本不允许访问uid/gid 25000/25000
拥有的/f5//public/assets/27ff0fb6。奇怪的是,我没有名为27ff0fb6
的资产子文件夹。您使用的是PHP版本<5.4,并且还设置了安全模式标志以检查uid(userId)/gid(groupId),同时允许系统文件权限级别之外的权限。有关如何使用/配置安全模式的详细信息,请参阅此页面