我有一个
PHP脚本,它创建一个目录并将图像输出到目录.这在Apache下运行得很好但我们最近决定切换到NGINX以更多地使用我们有限的RAM.我正在使用PHP mkdir()命令来创建目录:

mkdir(dirname($path['image']['server']),0755,true);

切换到NGINX后,我收到以下警告:

Warning: mkdir(): Permission denied in ...

我已经检查了父目录的所有权限,所以我确定我可能需要更改NGINX或PHP-FPM’用户’,但我不知道该怎么做(我从来没有指定用户APACHE的权限).我似乎无法找到关于此的更多信息.任何帮助都会很棒!

(注意:除了这个小小的挂机,转换到NGINX已经非常无缝了;我第一次使用它,它只花了大约10分钟才能启动和运行NGINX.现在我只是在熨烫解决问题.)

运行nginx& php-fpm as www:www

1. Nginx

编辑nginx.conf并将user设置为www www;

If the master process is run as root,then nginx will
setuid()/setgid() to USER/GROUP. If GROUP is not specified,then nginx
uses the same name as USER. By default it’s nobody user and nobody or
nogroup group or the –user=USER and –group=GROUP from the
./configure script.

2. PHP-FPM

编辑php-fpm.conf并将用户和组设置为www.

user – Unix user of processes. Default “www-data”

group – Unix group of processes. Default “www-data”

dawei

【声明】:唐山站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。