ubuntu 使用 www-data 執行 composer update 失敗

來源:互聯網
上載者:User
項目放在github,做了一個webhook, 自己的伺服器檢測來自github的post,如果master有變動,就執行

cd /path;git pull git@ooxxx.com

上面拉取代碼沒有問題。

最後同時還檢測master分支裡的compoer.json有改動的時候就執行一次:

php composer.phar updatephp composer.phar dump-autoload -o

由於來自github的post資料是用apache指定的www-data 執行 git pull(部署的public key也是這個使用者)發現並不能執行上面的composer操作,我在伺服器上手動操作 composer update 出現下面提示:

···
sudo -u www-data php composer.phar update
Cannot create cache directory /root/.composer/cache/repo/http---packagist.phpcomposer.com/, or directory is not writable. Proceeding without cache
Cannot create cache directory /root/.composer/cache/files/, or directory is not writable. Proceeding without cache
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files
···
同樣,我嘗試全域安裝composer,用 php /usr/local/bin/composer update 也是同樣的錯誤。

在GG上面搜尋,嘗試了把 /root/.composer 目錄改成www-data且 777

root@localhost:~# ls -la ~/.composer/cachetotal 20drwxrwxrwx 4 www-data www-data 4096 Dec 30 14:53 .drwxrwxrwx 3 www-data www-data 4096 Dec 30 14:53 ..drwxrwxrwx 2 www-data www-data 4096 Dec 30 14:53 files-rwxrwxrwx 1 www-data www-data   13 Dec 30 14:53 .htaccessdrwxrwxrwx 3 www-data www-data 4096 Dec 30 14:53 repo

除此之外 項目根目錄的composer.phar和/usr/local/bin/composer 擁有者都設定成為了www-data ,問題依舊。

請教怎麼解決。

ps:補充一下,用root 執行 composer update等操作沒有任何問題。

回複內容:

項目放在github,做了一個webhook, 自己的伺服器檢測來自github的post,如果master有變動,就執行

cd /path;git pull git@ooxxx.com

上面拉取代碼沒有問題。

最後同時還檢測master分支裡的compoer.json有改動的時候就執行一次:

php composer.phar updatephp composer.phar dump-autoload -o

由於來自github的post資料是用apache指定的www-data 執行 git pull(部署的public key也是這個使用者)發現並不能執行上面的composer操作,我在伺服器上手動操作 composer update 出現下面提示:

···
sudo -u www-data php composer.phar update
Cannot create cache directory /root/.composer/cache/repo/http---packagist.phpcomposer.com/, or directory is not writable. Proceeding without cache
Cannot create cache directory /root/.composer/cache/files/, or directory is not writable. Proceeding without cache
Loading composer repositories with package information
Updating dependencies (including require-dev)
Generating autoload files
···
同樣,我嘗試全域安裝composer,用 php /usr/local/bin/composer update 也是同樣的錯誤。

在GG上面搜尋,嘗試了把 /root/.composer 目錄改成www-data且 777

root@localhost:~# ls -la ~/.composer/cachetotal 20drwxrwxrwx 4 www-data www-data 4096 Dec 30 14:53 .drwxrwxrwx 3 www-data www-data 4096 Dec 30 14:53 ..drwxrwxrwx 2 www-data www-data 4096 Dec 30 14:53 files-rwxrwxrwx 1 www-data www-data   13 Dec 30 14:53 .htaccessdrwxrwxrwx 3 www-data www-data 4096 Dec 30 14:53 repo

除此之外 項目根目錄的composer.phar和/usr/local/bin/composer 擁有者都設定成為了www-data ,問題依舊。

請教怎麼解決。

ps:補充一下,用root 執行 composer update等操作沒有任何問題。

www-data 沒有許可權讀寫 /root 目錄。

改下緩衝目錄。

https://getcomposer.org/doc/03-cli.md#composer-cache-dir

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.