简体   繁体   English

PHP 即使文件夹权限为 777,mkdir() 也无法在 Mac OS X 上运行

[英]PHP mkdir() won't work on Mac OS X even if folder permissions are 777

I'm facing a strange issue.我面临一个奇怪的问题。 I cannot get mkdir() to work on Mac OS X in a directory that is under my home, using nginx + php70-fpm webserver.我无法使用 nginx + php70-fpm 网络服务器在我家目录下的 Mac OS X 上运行mkdir() nginx and php-fpm are installed from MacPorts . nginx 和 php-fpm 是从MacPorts安装的。 Coming from the Linux world, I have tried the following:来自 Linux 世界,我尝试了以下方法:

Edit /opt/local/etc/nginx/nginx.conf and add the user myusername directive and reload nginx, but no success.编辑/opt/local/etc/nginx/nginx.conf并添加user myusername指令并重新加载 nginx,但没有成功。 The server won't even start.服务器甚至不会启动。

Through the get info menu option, give permission to the folder I want to write to to everyone , but no success.通过get info菜单选项,将我要写入的文件夹权限授予everyone ,但没有成功。

From the console, chmod 777 the folder, but no success.从控制台, chmod 777文件夹,但没有成功。

Is there something I am missing?有什么我想念的吗?

Code:代码:

    if(!file_exists( dirname( __FILE__ ) . $ds. $storeFolder . $ds . $_SESSION["lid"] . $ds)) {
        // No directory, so create it
        if(mkdir(dirname( __FILE__ ) . $ds. $storeFolder . $ds . $_SESSION["lid"] . $ds, 0777, true)) {
            die("Folder creation failed");
        };
    }

Edit:编辑:

As an observation, after doing this you may face issues with phpMyAdmin saying incorrect permissions are applied.作为观察,执行此操作后,您可能会遇到 phpMyAdmin 的问题,表示应用了不正确的权限。 Therefore, some may find it useful to grand everyone "Read & Write" access only to the htdocs folder, or better yet, the specific folder for the project, not the whole XAMPP folder.因此,有些人可能会发现让每个人都“读写”访问 htdocs 文件夹很有用,或者更好的是,访问项目的特定文件夹,而不是整个 XAMPP 文件夹。

Here is the solution:这是解决方案:

  1. Open the applications folder打开应用程序文件夹

  2. Locate the XAMPP folder找到 XAMPP 文件夹

  3. right-click, and get info (as described above)右键单击并获取信息(如上所述)

  4. In the pop-up window, locate the 'sharing & permission' section在弹出窗口 window 中,找到“共享和许可”部分

  5. Click the 'locked' padlock symbol单击“锁定”挂锁符号

  6. Enter the administrator password输入管理员密码

  7. Change 'Everyone' permissions to read & write更改“所有人”的读写权限

  8. In the get info window still, select the 'cog' icon' drop down option at the very bottom and select 'Apply to enclosed items'.在获取信息 window 中,select 最底部的“齿轮”图标下拉选项和 select“应用于封闭的项目”。

    This will adjust the permission across all sub-folders as well.这也将调整所有子文件夹的权限。

  9. Re-lock the padlock symbol重新锁定挂锁符号

  10. Close the 'Get Info' window.关闭“获取信息”window。

The task is complete.任务完成。 This will now allow you to make directories.这将允许您创建目录。

I had the same problem. 我有同样的问题。 I'm not sure if your problem is the same as mine but I changed the permissions on the root folder to 777 and then everything worked fine. 我不确定您的问题是否与我的相同,但我将根文件夹的权限更改为777,然后一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM