How to solve linux php7-fpm startup failure

WBOY
Release: 2023-05-13 22:40:09
forward
2138 people have browsed it

Solution to the failure to start linux php7-fpm: 1. Modify the "error_log" item in the "php-fpm.conf" file; 2. Modify the location of the php configuration file; 3. , modify nginx to the user name of the current system; 4. Create nginx user and user group directly.

Solution to php-fpm startup failure (after installing PHP on centOS)

After compiling and installing php7.2.1 on centOS7.0, because of the newly added php extension, so you need to restart php-fpm;

1. First, let me talk about my configuration, about configuring php-fpm:

After the initial installation, these files are not available. You need to create cp one by one and then start it. If there is no error, you don’t need to read "2. php-fpm startup error:"

1. About configuring php-fpm

cp php.ini-development /usr/local/php7/etc/php.ini
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
Copy after login

2,

Start php-fpm:

/usr/local/php/sbin/php-fpm
Copy after login

2. php-fpm startup error:

Cause and solution:

1. Run it directly and find out if there is an error Can't find configuration file.

$ php-fpm

[11-Jan-2014 16:03:03] ERROR: failed to open configuration file '/private/etc/php-fpm.conf': No such file or directory (2)
[11-Jan-2014 16:03:03] ERROR: failed to load configuration file '/private/etc/php-fpm.conf'
[11-Jan-2014 16:03:03] ERROR: FPM initialization failed
Copy after login

You can generate the configuration file in the /private/etc/ directory, which requires root permissions (sudo)

Or place the configuration file in a directory with permissions for ordinary users, pass --fpm- The config parameter specifies the location of the configuration file, as follows:

# cp /private/etc/php-fpm.conf.default /etc/php-fpm.conf
$ php-fpm --fpm-config /etc/php-fpm.conf
[11-Jan-2014 16:10:49] ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
[11-Jan-2014 16:10:49] ERROR: failed to post process the configuration
[11-Jan-2014 16:10:49] ERROR: FPM initialization failed
Copy after login

The error message displays: The "log" file cannot be opened correctly. The reason is that it works in the /usr/var directory by default. You can modify the configuration file to specify the correct log. File path

$ vim /usr/local/etc/php-fpm.conf
Copy after login

Modify the error_log item in the php-fpm.conf file. The default prefix is ​​/usr/var, but there is no such path

error_log = /usr/local/var/log/php-fpm.log
pid = /usr/local/var/run/php-fpm.pid
Copy after login

or do not modify the configuration item in the configuration file. Path, in the running parameters of php-fpm (-p), specify the relative path prefix

$ php-fpm --fpm-config /php-fpm.conf  --prefix /usr/local/var
Copy after login

where the runtime file is placed. At this point, the php-fpm daemon can basically be started correctly.

Error message:

[12-Jul-2013 17:18:57] ERROR: [/usr/local/php5/etc/php-fpm.conf:144] value is NULL for a ZEND_INI_PARSER_ENTRY
[12-Jul-2013 17:18:57] ERROR: failed to load configuration file '/usr/local/php5/etc/php-fpm.conf'
[12-Jul-2013 17:18:57] ERROR: FPM initialization failed
Copy after login

2. The main cause of the error is /usr/local/php5/sbin/php-fpm configuration error, please check carefully. My mistake was that the = sign was missing here in group = www. So something went wrong

[root@localhost ~]# /usr/local/php5/sbin/php-fpm
PHP:  syntax error, unexpected TC_STRING in /usr/local/php5/etc/php.ini on line 211
Copy after login

3. When starting php-fpm, the error ERROR: [pool www] cannot get uid for user 'nginx'

Method 1:

When php7 is compiled Then use the following command to start

<code><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">/usr/local/php/sbin/php-fpm</pre><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div>

and then report this error:

[07-Dec-2018 17:59:31] ERROR: [pool www] cannot get uid for user &#39;nginx&#39;
[07-Dec-2018 17:59:31] ERROR: FPM initialization failed
Copy after login

Modify the configuration file location of php In www.conf

vi /usr/local/php/etc/php-fpm.d/www.conf
Copy after login

, modify nginx to the user name of the current system as follows:

; Unix user/group of processes
 ; Note: The user is mandatory. If the group is not set, the default user&#39;s group
 ;       will be used.
 user = www.emam.cn
 group = www.emam.cn
Copy after login

Method 2:

Create nginx user and user group directly

useradd nginx
groupadd nginx
usermod -G nginx nginx
Copy after login

3. php-fpm content expansion

Start php-fpm:

<code><div class="code" style="position:relative; padding:0px; margin:0px;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:php;toolbar:false">/usr/local/php/sbin/php-fpm</pre><div class="contentsignin">Copy after login</div></div><div class="contentsignin">Copy after login</div></div>

php 5.3.3 and later php-fpm no longer supports commands such as /usr/local/php/sbin/php-fpm (start|stop|reload) that php-fpm previously had, so don’t look at this old-fashioned command anymore, you need to use signal control :

The master process can understand the following signals

INT, TERM Terminate immediately

QUIT Terminate smoothly

USR1 Reopen the log file

USR2 smoothly reloads all worker processes and reloads configuration and binary modules

A simple and direct restart method:

Check the master process number of php-fpm first

# ps aux|grep php-fpm
root     21891  0.0  0.0 112660   960 pts/3    R+   16:18   0:00 grep --color=auto php-fpm
root     42891  0.0  0.1 182796  1220 ?        Ss   4月18   0:19 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nobody   42892  0.0  0.6 183000  6516 ?        S    4月18   0:07 php-fpm: pool www
nobody   42893  0.0  0.6 183000  6508 ?        S    4月18   0:17 php-fpm: pool www
Copy after login

Restart php-fpm:

kill -USR2 42891
Copy after login

OK.

The above scheme is generally used when the php-fpm.pid file is not generated. If you want to generate php-fpm.pid, use the following scheme:

You can see the above master process, matster The configuration file /usr/local/php/etc/php-fpm.conf is used. Cat /usr/local/php/etc/php-fpm.conf found:

[global]
; Pid file
; Note: the default prefix is /usr/local/php/var
; Default Value: none
;pid = run/php-fpm.pid
Copy after login

pid file path should be located at /usr/local/php/var/run/php-fpm.pid, because it was commented out, it was not generated. We remove the comment, then kill -USR2 42891 and restart php-fpm, the pid file will be generated. It will be OK next time. Use the following command to restart and close php-fpm:

php-fpm Close:

kill -INT &#39;cat /usr/local/php/var/run/php-fpm.pid&#39;
Copy after login

php-fpm Restart:

kill -USR2 &#39;cat /usr/local/php/var/run/php-fpm.pid&#39;
Copy after login

The above is the detailed content of How to solve linux php7-fpm startup failure. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template