PHP mkdir() 权限
我有一个 Linux 服务器,使用 appache 作为 Web 服务器。在我的 PHP 脚本中,我使用 0777
模式创建目录。代码非常简单,如下所示:
mkdir($path,0777)
当我运行此脚本并转到我的服务器文件管理器时,该文件夹就在那里,但分配给该文件夹的权限是 0755。我不明白为什么会发生这种情况!创建文件夹时,用户列中有 apache,但权限为 0755。
I have a Linux server with appache as the web server. In my PHP script I am making directories with 0777
mode. the code is pretty simple as follows:
mkdir($path,0777)
when I run this script and go to my server file manager, the folder is there but the permission assigned to that folder is 0755. I can't figure out why this is happening!! when the folder is created the user column has apache in it but the permission is 0755.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您应该尝试使用 umask
You should try with the umask
您可以尝试:
看看是否可以解决权限问题。
You can try:
See if that can fix the permissions issue.
Apache 可能没有更改此设置的权限。你能做的就是。确保 apache 与当前文件组在同一组中运行。然后 apache 将能够更改该文件。您可以在此 apache 配置中更改您的 apache 组。或者最简单的方法就是将整个项目用户改为apache用户。然后apache就可以让我们改变它想要的。
从服务器转到该文件并输入 ls -al 并查看用户和组
Apache might not have the permissions to change this. What you can do is. Make sure that apache is running in the same group as your current files group. Then apache will be able to make changes to that file. You can change you apache group in this apache config. Or the easiest way is to change the entire project user to be the apache user. Then apache can make w.e changes it wants.
go to the file from your server and type ls -al and look at the user and group
可能是你的 umask:
Could be your umask: