gpt4 book ai didi

php - 无法启动 php,因为它无法创建 PID 文件

转载 作者:行者123 更新时间:2023-12-05 01:01:09 35 4
gpt4 key购买 nike

如果我尝试启动 PHP-FPM,我会收到此错误:

ERROR: Unable to create the PID file (/var/run/php-fpm/php-fpm.pid).: No such file or directory ERROR: FPM initialization failed

我是否必须在 systemctl .service 文件中授予权限,以便它可以创建文件夹和文件?

这是我的 php.service 文件:

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=notify
EnvironmentFile=/etc/opt/remi/php70/sysconfig/php-fpm
ExecStart=/opt/remi/php70/root/usr/sbin/php-fpm --nodaemonize
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

www.conf 文件中有一个用户和组设置为 apache。我尝试将其更改为 root,但随后我收到消息“尝试其他用户而不是 root”。我也尝试过 nginx,但又遇到了之前的错误。

这是我的 www.conf

; Start a new pool named 'www'.
; the variable $pool can we used in any directive and will be replaced by the
; pool name ('www' here)
[www]

; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or @php_fpm_prefix@) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = apache
; RPM: Keep a group allowed to write in log dir.
group = apache

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = 127.0.0.1:9000

; Set listen(2) backlog.
; Default Value: 511
;listen.backlog = 511

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server.
; Default Values: user and group are set as the running user
; mode is set to 0660
;listen.owner = nobody
;listen.group = nobody
;listen.mode = 0660

; When POSIX Access Control Lists are supported you can set them using
; these options, value is a comma separated list of user/group names.
; When set, listen.owner and listen.group are ignored
;listen.acl_users = apache,nginx
;listen.acl_groups =

; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect.
; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original
; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address
; must be separated by a comma. If this value is left blank, connections will be
; accepted from any ip address.
; Default Value: any
"www.conf" 422L, 18812C

编辑:我错过了 /var/run/php-fpm/ 文件夹。我已经添加了,现在可以运行了。

最佳答案

ERROR: Unable to create the PID file (/var/run/php-fpm/php-fpm.pid).: No such file or directory

表示目录/var/run/php-fpm/不存在。您应该将此目录添加到 tmpfiles.d配置。例如,将以下行添加到 /usr/lib/tmpfiles.d/php-fpm.conf:

d /var/run/php-fpm 755 root root

php.service 文件的 [Service] 部分中设置 PIDFile:

PIDFile=/var/run/php-fpm/php-fpm.pid

重新安装并启动服务:

systemctl disable php.service
systemctl enable php.service
systemctl start php.service

关于php - 无法启动 php,因为它无法创建 PID 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45540492/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com