授予 Apache 文件夹权限
我已经安装了 Centos5,安装了 Web 服务器并设置了虚拟主机。主机几乎是这样设置的:
> adduser user1
> mkdir -p /home/user1/public_html/domain1.com/{public,private,log,cgi-bin,backup}
> chmod -R 755 /home/user1/public_html/
我在 httpd.conf 中添加了一个 VirtualHost
条目,如下所示:
<VirtualHost *:80>
#Blah blah blah
DocumentRoot /home/user1/public_html/domain1.com/public
#Blah blah blah
</VirtualHost>
所以 apache 可以很好地准备好目录,但在上传文件时遇到问题,因为权限被拒绝。脚本语言是PHP。
如何允许文件上传而不将所有内容设为 777 权限?
I've installed Centos5, installed a web server and set up virtual host. The host is pretty much set up like this:
> adduser user1
> mkdir -p /home/user1/public_html/domain1.com/{public,private,log,cgi-bin,backup}
> chmod -R 755 /home/user1/public_html/
And I've added a VirtualHost
entry in httpd.conf that looks like this:
<VirtualHost *:80>
#Blah blah blah
DocumentRoot /home/user1/public_html/domain1.com/public
#Blah blah blah
</VirtualHost>
So apache can ready the directory just fine but has problems uploading files because the permission is denied. The scripting language is PHP.
How can I allow file uploads without making everything 777 permssion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
chown 目录以匹配 Apache 的配置用户名/组名,并检查 PHP 上传的位置
Apache 的用户/组由
User
和Group
.conf 选项定义,而 PHP 的上传目录由upload_tmp_dir
.ini 选项指定。chown the directory to match Apache's configured username/groupname, and check where PHP is putting its uploads
Apache's user/group are defined by the
User
andGroup
.conf options, and PHP's upload dir is specified by theupload_tmp_dir
.ini option.将所有文件夹设为 755 并将所有者更改为运行 apache 的用户。通常在 Centos 中应该是 httpd
make all folders 755 and change the owner to the user who is running apache. Usually in Centos should be httpd
将文件上传到文档根目录之外的其他位置
upload files someplace other then the docroot