php-fpm 的各种启动方式
<p> </p><p><span style="font-size: 15px"> 启动 php-fpm 最简单的操作:</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">/usr/local/php/sbin/php-fpm</span></pre>
</div>
<p> </p>
<p><span style="font-size: 15px"> <span style="color: rgba(255, 0, 0, 1)">php 5.3.3</span> 以后的php-fpm 不再支持 php-fpm 以前具有的 /usr/local/php/sbin/php-fpm (start|stop|reload)等命令,所以不要再看这种老掉牙的命令了,需要使用<span style="color: rgba(255, 0, 0, 1)">信号控制</span>:</span></p>
<p><span style="font-size: 15px"> master进程可以理解以下信号:</span></p>
<ul>
<li><span style="font-size: 15px"><span style="color: rgba(255, 0, 0, 1)">INT, TERM </span> 立刻终止</span></li>
<li><span style="font-size: 15px"><span style="color: rgba(255, 0, 0, 1)">QUIT </span> 平滑终止</span></li>
<li><span style="font-size: 15px"><span style="color: rgba(255, 0, 0, 1)">USR1 </span> 重新打开日志文件</span></li>
<li><span style="font-size: 15px"><span style="color: rgba(255, 0, 0, 1)">USR2 </span> 平滑重载所有worker进程并重新载入配置和二进制模块</span></li>
</ul>
<p> </p>
<p> 一个简单直接的重启方法:</p>
<p> 先查看php-fpm的master进程号</p>
<div class="cnblogs_code">
<pre># <span style="color: rgba(0, 0, 255, 1)">ps</span> -ef|<span style="color: rgba(0, 0, 255, 1)">grep</span> php-<span style="color: rgba(0, 0, 0, 1)">fpm
root </span><span style="color: rgba(128, 0, 128, 1)">27556</span> <span style="color: rgba(128, 0, 128, 1)">1</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">15</span>:<span style="color: rgba(128, 0, 128, 1)">57</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> php-fpm: master process (/usr/local/php/etc/php-<span style="color: rgba(0, 0, 0, 1)">fpm.conf)
www </span><span style="color: rgba(128, 0, 128, 1)">27557</span> <span style="color: rgba(128, 0, 128, 1)">27556</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">15</span>:<span style="color: rgba(128, 0, 128, 1)">57</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> php-<span style="color: rgba(0, 0, 0, 1)">fpm: pool www
www </span><span style="color: rgba(128, 0, 128, 1)">27558</span> <span style="color: rgba(128, 0, 128, 1)">27556</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">15</span>:<span style="color: rgba(128, 0, 128, 1)">57</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> php-<span style="color: rgba(0, 0, 0, 1)">fpm: pool www
www </span><span style="color: rgba(128, 0, 128, 1)">27559</span> <span style="color: rgba(128, 0, 128, 1)">27556</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">15</span>:<span style="color: rgba(128, 0, 128, 1)">57</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> php-<span style="color: rgba(0, 0, 0, 1)">fpm: pool www
www </span><span style="color: rgba(128, 0, 128, 1)">27560</span> <span style="color: rgba(128, 0, 128, 1)">27556</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">15</span>:<span style="color: rgba(128, 0, 128, 1)">57</span> ? <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> php-<span style="color: rgba(0, 0, 0, 1)">fpm: pool www
root </span><span style="color: rgba(128, 0, 128, 1)">27733</span> <span style="color: rgba(128, 0, 128, 1)">26938</span><span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">16</span>:<span style="color: rgba(128, 0, 128, 1)">35</span> pts/<span style="color: rgba(128, 0, 128, 1)">0</span> <span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span>:<span style="color: rgba(128, 0, 128, 1)">00</span> <span style="color: rgba(0, 0, 255, 1)">grep</span> php-fpm </pre>
</div>
<p> 重启 php-fpm:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">kill</span> -USR2 <span style="color: rgba(128, 0, 128, 1)">27556</span></pre>
</div>
<p> 这样就OK了。 </p>
<p> </p>
<p> 上面方案一般是没有生成php-fpm.pid文件时使用,如果要生成php-fpm.pid,使用下面这种方案:</p>
<p> 上面master进程可以看到,matster使用的是/usr/local/php/etc/php-fpm.conf这个配置文件,cat /usr/local/php/etc/php-fpm.conf 发现:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 0, 1)">
; Pid </span><span style="color: rgba(0, 0, 255, 1)">file</span><span style="color: rgba(0, 0, 0, 1)">
; Note: the default prefix is </span>/usr/local/php/<span style="color: rgba(0, 0, 0, 1)">var
; Default Value: none
;pid </span>= run/php-fpm.pid</pre>
</div>
<p> pid文件路径应该位于/usr/local/php/var/run/php-fpm.pid,由于注释掉,所以没有生成,我们把注释去除,再kill -USR2 42891 重启php-fpm,便会生成pid文件,下次就可以使用以下命令重启,关闭php-fpm了:</p>
<p> php-fpm 关闭:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">kill</span> -INT <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">cat /usr/local/php/var/run/php-fpm.pid</span><span style="color: rgba(128, 0, 0, 1)">'</span></pre>
</div>
<p> php-fpm 重启:</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">kill</span> -USR2 <span style="color: rgba(128, 0, 0, 1)">'</span><span style="color: rgba(128, 0, 0, 1)">cat /usr/local/php/var/run/php-fpm.pid</span><span style="color: rgba(128, 0, 0, 1)">'</span></pre>
</div><br><br>
来源:https://www.cnblogs.com/morgan363/p/12125187.html
頁:
[1]