php-phantomjs:如何启用磁盘缓存

Although phantomjs has a disk-cache option that works when running via command line, when I use php-phantomjs no disk caching is created.
Is there any specific setting I should set on PHP or Apache so that php-phantomjs uses disk-cache?

Think I found out how to answer my own question:

  1. Make sure that Apache user's home is writable by the user running Apache, or at least that $HOME/.qws is writable by that user.
  2. Set $HOME enviroment variable on PHP script:
    $apacheUserData = posix_getpwuid(posix_getuid()); putenv('HOME='.$apacheUserData['dir']);

With the above steps phantomjs binary running from PHP knows how to find Apache's user dir and is also able to write to $HOME/.qws.