PHP mkdir:权限被拒绝的问题 [英] PHP mkdir: Permission denied problem

查看:177
本文介绍了PHP mkdir:权限被拒绝的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用PHP mkdir函数创建目录,但出现如下错误:Warning: mkdir() [function.mkdir]: Permission denied in ....如何解决这个问题?

I am trying to create a directory with PHP mkdir function but I get an error as follows: Warning: mkdir() [function.mkdir]: Permission denied in .... How to settle down the problem?

推荐答案

我知道这是一个旧线程,但是需要一个更好的答案.您不需要将权限设置为777,这是一个安全问题,因为它提供了对世界的读写访问权限.可能是您的apache用户对该目录没有读/写权限.

I know this is an old thread, but it needs a better answer. You shouldn't need to set the permissions to 777, that is a security problem as it gives read and write access to the world. It may be that your apache user does not have read/write permissions on the directory.

这就是您在Ubuntu中所做的

Here's what you do in Ubuntu

  1. 确保所有文件均归Apache组和用户所有.在Ubuntu中,它是 www-data 组和用户

chown -R www-data:www-data /path/to/webserver/www

下一步使www-data组的所有成员能够读写文件

Next enabled all members of the www-data group to read and write files

chmod -R g+rw /path/to/webserver/www

php mkdir()函数现在应该可以正常工作而不会返回错误

The php mkdir() function should now work without returning errors

这篇关于PHP mkdir:权限被拒绝的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆