首页 > 解决方案 > 在 stderr 中发送的 FastCGI:“PHP 消息:PHP 警告:mkdir():只读文件系统

问题描述

我正在nginx 1.16.1运行php 7.4.0Manjaro KDE 18.1.4

我在 pure 上有一个非常相似的设置,arch Linux arm其中以下设置运行没有问题。

我尝试设置一个 yii2 项目,输入时显示以下错误ig-net.at

该目录不可被 Web 进程写入

或者

创建目录“/usr/share/nginx/html/ig-net/runtime”失败:mkdir():只读文件系统

nginx 错误日志显示以下错误:

在标准错误中发送的 FastCGI:“PHP 消息:PHP 警告:mkdir():只读

网站所在的html文件夹位于/usr/share/nginx/html/并相应地更改了权限

chmod -R g+w /usr/share/nginx/html/
chgrp -R http /usr/share/nginx/html/
chown -R http /usr/share/nginx/html/

nginx 和 php-fpm 的两个进程都与http用户一起运行。

ps aux | grep nginxps aux | grep php-fpm返回以下内容:

root      6294  0.0  0.0  11868  1252 ?        Ss   15:33   0:00 nginx: master process /usr/bin/nginx -g pid /run/nginx.pid; error_log stderr;
http      6295  0.0  0.0  12496  4352 ?        S    15:33   0:00 nginx: worker process

root      3393  0.0  0.3  88140 26844 ?        Ss   14:15   0:00 php-fpm: master process (/etc/php/php-fpm.conf)
http      3395  0.0  0.2  92988 19512 ?        S    14:15   0:00 php-fpm: pool www
http      3396  0.0  0.2  92988 19776 ?        S    14:15   0:01 php-fpm: pool www

nginx 配置文件看起来像这样

user http;
worker_processes  1;

error_log  /var/log/nginx/error.log;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    server {
        listen       80;
        server_name  _;
        root   /usr/share/nginx/html;
        index index.php index.html index.htm;

        location / {
            try_files $uri $uri/ @rewrite;
        }

        location @rewrite {
                rewrite /.* /index.php;
        }

        location ~ \.php$ {
            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            include        fastcgi.conf;
            fastcgi_read_timeout 180;
        }

        location ~ /\.ht {
            deny  all;
        }
    }


    server {
        listen 80;
        listen [::]:80;

        server_name ig-net.at;

        root /usr/share/nginx/html/ig-net/web;
        index index.php index.html index.htm;

        location / {
            try_files $uri $uri/ @rewrite;
        }

        location @rewrite {
                rewrite /.* /index.php;
        }
        location ~ \.php$ {
            fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            include        fastcgi.conf;
            fastcgi_read_timeout 180;
        }
    }
}

我还尝试在终端中与http用户一起创建一个文件夹,它可以正常工作。

那么 Web 进程无法正常工作的问题是什么?

谢谢, 卢克

标签: phpnginxmanjaro

解决方案


我猜为什么用户http只写/srv/http是因为它是用户的默认主目录。

看:

# grep http /etc/passwd
http:x:33:33::/srv/http:/usr/bin/nologin

推荐阅读