Macos Monterey上的php-fpm |无法访问外部驱动器上的文件
我是从源(不是由Homebrew或Macports)编译的PHP8,PHP-FPM和MacOS上的Nginx,MacOS 12.4 Monterey
i正确配置了它们。
一切正常,除了PHP无法读取或编写存储在外部驱动器上的文件。
我在文件上检查了权限,允许R+W访问PHP-FPM和NGINX的用户/组,
我允许完整的磁盘访问通过System Persecens =>安全=>隐私
我还尝试在外部卷上禁用所有权:
sudo diskutil disapewownhiphersion/lumpes/storage
file_get_contents
仍然失败报告不允许操作
此问题仅影响此问题Web服务器执行的代码。
我将网站的DIDETORY移至外部驱动器,并在此处设置Nginx的根源:Nginx能够提供静态内容。
从CLI调用的PHP脚本可以在外部或远程卷上读取文件,而没有任何问题。
鉴于以上,我认为问题是PHP-FPM,但我无法弄清楚。
Update
如果我启动 php-fpm 通过使用sudo php-fpm
的终端>,那么它可以访问外部驱动器中的文件。
如果该过程是由启动
启动的,则不是。
I compiled from source (not via HomeBrew or MacPorts) php8, php-fpm and nginx on macOS 12.4 Monterey
I properly configured them.
Everything works fine except that PHP isn't able to read or write files stored on external drives.
I checked permissions on files allow r+w access to both php-fpm's and nginx's user/group
I allowed full disk access to php, php-fpm, nginx and launchd via System Preferences => Security => Privacy
I also tried disabling ownership on the external volume:
sudo diskutil disableOwnership /Volumes/Storage
file_get_contents
still fails reporting Operation not permitted
This problem affects only code executed by the web server.
I moved the website diretory to the external drive and set nginx's root there: nginx is able to serve static content.
PHP Scripts invoked from the CLI can read and write files on external or remote volumes without any problem.
Given the above I assume the issue is with php-fpm but I can't figure it out.
Update
if I start php-fpm via terminal with sudo php-fpm
then it is able to access files in external drives.
If the process is started by launchd
it is not.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最后,我找到了原因:
我有一个启动daemon,可以执行bash脚本
webstack.sh
。该脚本启动Nginx和PHP-FPM,并在不太可能崩溃的情况下重新启动它们。
启动daemon使用
sh
在我的系统上执行脚本和sh
没有完整的磁盘访问。ZSH
具有完整的磁盘访问,因此我用zsh
更改了sh
,现在php-fpm可以访问外部驱动器。Finally I found the cause:
I have a LaunchDaemon that executes the bash script
webstack.sh
.The script launches nginx and php-fpm and restart them in the unlikely case they crash.
The LaunchDaemon use
sh
to execute the script andsh
on my system does not have full disk access.zsh
has full disk access so I changedsh
withzsh
and now php-fpm can access external drives.