sub*_*arb 27 permissions symfony
这个问题已被多次询问,但没有一个解决方案可以解决我的问题.
我在Mac OSX Lion上运行Apache.此http://localhost/Symfony/web/config.php
URL触发了两个主要问题:
Change the permissions of the "app/cache/" directory so that the web server can write into it.
Change the permissions of the "app/logs/" directory so that the web server can write into it.
Run Code Online (Sandbox Code Playgroud)
按照"设置权限"下的指南进行操作:
rm -rf app/cache/*
rm -rf app/logs/*
sudo chmod +a "_www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
Run Code Online (Sandbox Code Playgroud)
这并没有解决问题,所以我尝试了:
sudo chmod -R 777 app/cache
Run Code Online (Sandbox Code Playgroud)
这也行不通.任何想法如何解决这一问题?
fse*_*art 50
一些初步解释:
app/cache
目录来实现.app/logs
目录来实现此目的.关于Apache的一些话:
user
和特定的group
(通常www-data
为两个,但你必须检查你的安装,找到使用的.例如,如果你在搜索/etc/apache2/envvars
在Linux中,你将有两个变量APACHE_RUN_USER=www-data
和APACHE_RUN_GROUP=www-data
).user
和group
.分析你的问题:
首先,你有错误,如:
Change the permissions of the "app/cache/" directory so that the web server can write into it.
Change the permissions of the "app/logs/" directory so that the web server can write into it.
Run Code Online (Sandbox Code Playgroud)
因为你app/cache
和app/logs
文件夹无法写入你的Apache user
和group
.
其次,通过执行:
sudo chmod +a "_www allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
sudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
Run Code Online (Sandbox Code Playgroud)
您正在修改和文件夹的访问控制列表(ACL),以便授予(基本上你)和.这种方法不起作用,可以有两个来源:app/cache
app/logs
whoami
_www
您正在修改ACL,但您的内核和文件系统是否配置为考虑ACL?
你是给一些权限whoami
和_www
,但你检查你的Apache实例,这些用户中的一个下运行?
第三,您的同事通过执行以下方式解决问题:
sudo chmod -R 777 app/cache
Run Code Online (Sandbox Code Playgroud)
这种方法有效,原因有两个:
777
),因此您确信至少您的Apache用户和组还具有写入所需的权限app/cache
.-R
)方式执行它,因此在app/cache
目录中创建的所有嵌套文件夹也与新权限有关.简单方案:
删除您app/cache
和app/logs
文件夹的内容:
rm -rf app/cache/*
rm -rf app/logs/*
Run Code Online (Sandbox Code Playgroud)授予您app/cache
和app/logs
文件夹的所有权限(读取和写入):
chmod 777 app/cache
chmod 777 app/logs
Run Code Online (Sandbox Code Playgroud)备注:
该指导下的"设置权限"说,如果你的系统不支持使用chmod +一个你必须这样做:
HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\ -f1`
sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX app/cache app/logs
Run Code Online (Sandbox Code Playgroud)
如果这不起作用试试这个:
umask(0002); // This will let the permissions be 0775
// or
umask(0000); // This will let the permissions be 0777
Run Code Online (Sandbox Code Playgroud)
第一个解决方案适合我.我希望它可以帮助有相同类型问题的人.