【问题标题】:mkdir error. permission denied. google apimkdir 错误。没有权限。谷歌API
【发布时间】:2015-10-29 16:27:45
【问题描述】:

我正在尝试使用具有 Google API 的服务帐户来使用 php 添加日历事件。我已经在一个网站上完美地工作了。当我将它移到同一服务器上的另一个站点时,我突然开始收到以下错误消息:

~PHP 警告:mkdir(): Permission denied in Google/Cache/File.php

~未捕获的异常“Google_Cache_Exception”和消息“无法创建存储目录:在 Google/Cache/File.php 中

据我所知,这两个环境是相同的 ~同一台服务器 ~所有文件/文件夹的权限相同 〜相同的凭据 ~在 Google 的控制台中授权的两个 URLs

我检查了我的服务器,看看是否有问题在被赞成的答案here 中,但我确信一切设置正确。

我已经进行了大量搜索和阅读,但无法想象当其他站点的一切正常时可能导致这些错误的原因。

任何帮助将不胜感激!

【问题讨论】:

    标签: google-api file-permissions mkdir


    【解决方案1】:

    如果有人遇到这个问题:我按照此处给出的建议解决了这个问题: A client error occurred: Could not create storage directory: /tmp/Google_Client/00

    具体来说,我在我的 tmp 目录中手动添加了嵌套文件夹(google 和缓存),然后使用此代码(来自上面的链接)为 google 设置它的路径:

    $config = new Google_Config();
    $config->setClassConfig('Google_Cache_File', array('directory' => '../../tmp/google/cache'));
    // Here I set a relative folder to avoid pb on permissions to a folder like /tmp that is not permitted on my mutualised host
    
    $client = new Google_Client($config);
    

    【讨论】:

      【解决方案2】:

      将此 PHP 代码添加到您的脚本中:

      $client = new Google_Client();
      $client->setCache(new Google_Cache_File('/path/to/shared/cache'));
      

      【讨论】:

      • 更多细节将不胜感激
      【解决方案3】:

      万一有人需要这样做。我正在使用 Codeigniter,最近从 Windows 7 移至 Mac 上的 osx el capitan。我的 google 缓存文件夹具有读写管理员权限,但错误仍然存​​在:mkdir 权限被拒绝,在 google/cache/file.php 上

      我查看了加载 google api 并添加的代码>

      $config = new Google_Config();
      $config->setClassConfig('Google_Cache_File', array('directory' => 'application/third_party/Google/src/Google/Cache/'));
      $client = new Google_Client($config);
      

      因此,您可以通过这些行设置缓存文件夹。

      希望这对我有所帮助。

      【讨论】:

        猜你喜欢
        • 2016-04-01
        • 1970-01-01
        • 2017-07-31
        • 1970-01-01
        • 1970-01-01
        • 2017-03-18
        • 2019-10-28
        • 2010-12-10
        • 1970-01-01
        相关资源
        最近更新 更多