Error when try to create my own api.


I've try to create my own api (bridge) to work with XenForo core, here is my demo api.php code:

    ini_set("display_errors", 1);   
    *** INIT XF
    define('SCRIPT_ROOT', empty($_SERVER['SCRIPT_FILENAME']) ? '../' : dirname(dirname($_SERVER['SCRIPT_FILENAME'])).'/');
    require_once(SCRIPT_ROOT. '/library/XenForo/Autoloader.php');
    XenForo_Autoloader::getInstance()->setupAutoloader(SCRIPT_ROOT. '/library');
    XenForo_Application::initialize(SCRIPT_ROOT . '/library', SCRIPT_ROOT);
    XenForo_Application::set('page_start_time', microtime(TRUE));

    $deps = new XenForo_Dependencies_Public();
This is my forum struct:


And I always see this error:
An exception occurred: cache_dir must be a directory in /var/www/ on line 209

Zend_Cache::throwException() in /var/www/ at line 154
Zend_Cache_Backend_File->setCacheDir() in /var/www/ at line 121
Zend_Cache_Backend_File->__construct() in /var/www/ at line 153
Zend_Cache::_makeBackend() in /var/www/ at line 94
Zend_Cache::factory() in /var/www/ at line 753
call_user_func_array() in /var/www/ at line 960
XenForo_Application->lazyLoad() in /var/www/ at line 991
XenForo_Application::get() in /var/www/ at line 1601
XenForo_Application::getCache() in /var/www/ at line 146
XenForo_Model->_getCache() in /var/www/ at line 81
XenForo_Model_DataRegistry->getMulti() in /var/www/ at line 147
XenForo_Dependencies_Abstract->preLoadData() in /var/www/ at line 14
Any idea? Look like the cache_dir is wrong here, but I don't know where to fix. Thanks