Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CAssetManager.basePath "/assets" is invalid. Please make sure the directory exists and is writable by the Web server process.?

Tags:

yii

When I run my YII Project on server , I got this error.

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();

I do Not know ,how to resolve it?Please Explain solution of it?

This is my Project Structure

assets
protected <-- Yii app
js
css
yii
like image 568
unknownbits Avatar asked Oct 02 '22 10:10

unknownbits


1 Answers

assets folder should be writable by your web server process. Usually it is www-data if on apache configured by default. You can either add the user to the folder group with '+w' permission modifications

Alternatively just modify the permissions to 777 as assets folder will only contain your js and css files which will be exposed to the public anyway from your root directory

chmod 777 -R ./assets

You will also face the same issue with runtime and data/auth.php(if app is configured for using Yii auth roles), you can do similar suitable modifications there as well

UPDATE:: Additional Settings for PHP < 5.4 is required if safe-mode flags are set ( this was depreciated in 5.4 ) refer to http://php.net/manual/en/ini.sect.safe-mode.php on how to configure safe-mode settings in your php.ini file. Either you can set the flags fully off or exclude the directories in question. ( This step is not needed if you have added www-data(your web-process) to your group as the gid will then match automatically

like image 94
Manquer Avatar answered Oct 12 '22 00:10

Manquer