CakePHP安装错误,无法打开流

时间:2018-06-11 02:04:01

标签: cakephp

我打算学习cakePHP。我已经在全球范围内安装了composer,但每当我运行composer self-update&&作曲家创建项目--prefer-dist cakephp / app my_app,我收到一个错误说:

[ErrorException]
copy(/Users/a/.composer/cache/files/cakephp/cakephp/4528680ebd888b7778e5755c957f
c9a26a0d10d1.zip):failed to open stream: Permission denied.

确切地说,此错误在ff之后运行:

- Installing cakephp/plugin-installer(1.1.0): Loading from cache
- Installing aura/intl (3.0.0): Loading from cache
- Installing psr/http-message (1.0.1): Loading from cache
- Installing zendframework/zend-diactoros (1.7.2): Loading from cache
- Installing psr/log (1.0.2): Loading from cache
- Installing cakephp/chronos (1.1.4): Loading from cache
- Installing cakephp/cakephp (3.6.5): Downloading (100%)

我也尝试过

sudo composer self-update && composer create-project --prefer-dist cakephp/app my_app

但仍然存在错误。任何想法为什么会这样?

2 个答案:

答案 0 :(得分:0)

使用 chown -R 设置缓存目录的所有权,这将递归更改缓存目录中所有文件和文件夹的所有权

Reference

答案 1 :(得分:0)

将目录更改为您的项目目录:

cd cakePHPproject

如果您知道您的Web服务器在什么用户下运行,则:

chown -R "userWebserverIsRunning" . *不带“”

以上将递归(-R)更改当前目录(。)中文件的所有者。

也可以设置:

chmod -R 777 tmp
chmod -R 777 logs

PS,如果您不知道您的网络服务器在哪个用户下运行,请运行:

ps -ef | egrep '(httpd|apache2|apache)' | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}'

您可以阅读Cake的文档的更多信息:

https://book.cakephp.org/3.0/en/tutorials-and-examples/blog/blog.html#directory-permissions-on-tmp-and-logs

玩得开心!

相关问题