最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

php7中停止php-fpm服務(wù)的方法詳解

 更新時(shí)間:2021年04月12日 10:59:48   作者:guangsu.  
這篇文章主要給大家介紹了關(guān)于php7中如何停止php-fpm服務(wù)的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

在PHP生命周期的各個(gè)階段,一些與服務(wù)相關(guān)的操作都是通過SAPI接口實(shí)現(xiàn)。

各個(gè)服務(wù)器抽象層之間遵守著相同的約定,這里我們稱之為SAPI接口。

在PHP的源碼中,當(dāng)需要調(diào)用服務(wù)器相關(guān)信息時(shí),全部通過SAPI接口中對(duì)應(yīng)的方法調(diào)用實(shí)現(xiàn)

php-fpm + nginx
php + terminal
... 

PHP常見的四種運(yùn)行模式

SAPI(Server Application Programming Interface)服務(wù)器應(yīng)用程序編程接口,即PHP與其他應(yīng)用交互的接口.
每個(gè)SAPI實(shí)現(xiàn)都是一個(gè)_sapi_module_struct結(jié)構(gòu)體變量。

PHP腳本要執(zhí)行有很多方式,通過Web服務(wù)器,或者直接在命令行下,也可以嵌入在其他程序中。

SAPI提供了一個(gè)和外部通信的接口,常見的SAPI有:cgi、fast-cgi、cli、isapi apache模塊的DLL

  1. ISAPI模式 (eg Apache : apache2handler mode ) 以web服務(wù)器的一個(gè)模塊加載運(yùn)行,其實(shí)就是將PHP的源碼與webServer的代碼一起編譯,運(yùn)行時(shí)是同一個(gè)進(jìn)程,共享同一個(gè)地址空間. 例如 LAMP中,PHP就是作為Apache的一個(gè)模塊運(yùn)行的.Apache是多線程調(diào)用php模塊的.(same as IIS)
  2. CGI模式 fork-and-execute webServer將動(dòng)態(tài)請(qǐng)求轉(zhuǎn)發(fā)到CGI程序(以php為例子),就相當(dāng)于fork一個(gè)子進(jìn)程,然后exec(php process),用CGI程序來解釋請(qǐng)求內(nèi)容,最后將子進(jìn)程的output返回.此時(shí)webServer與php進(jìn)程的地址空間是獨(dú)立的.此時(shí)的php是作為一個(gè)獨(dú)立的程序運(yùn)行.
  3. FastCGI模式 這種形式是CGI的加強(qiáng)版本,CGI是單進(jìn)程,多線程的運(yùn)行方式,程序執(zhí)行完成之后就會(huì)銷毀,所以每次都需要加載配置和環(huán)境變量(創(chuàng)建-執(zhí)行)。
    而FastCGI則不同,F(xiàn)astCGI 是一個(gè)常駐 (long-live) 型的 CGI,它可以一直執(zhí)行著,只要激活后,不會(huì)每次都要花費(fèi)時(shí)間去 fork 一次。
  4. CLI command line interface

CLI

php_module_startup
php_request_startup
php_execute_script
php_request_shutdown
php_module_shutdown

PHP-FPM

php 5.3.3 以后的php-fpm不再支持php-fpm (start|stop|reload)等命令,需要使用信號(hào)控制.php-fpm master進(jìn)程可以理解以下信號(hào)

  • kill -USR1 "php-fpm master pid" 重新打開日志文件. 執(zhí)行完畢后 你會(huì)發(fā)現(xiàn)php-fpm master/worker進(jìn)程id not change
  • kill -USR2 "php-fpm master pid" 平滑重載所有php-fpm進(jìn)程,執(zhí)行完畢后你會(huì)發(fā)現(xiàn)php-fpm master/worker進(jìn)程id have changed.
  • kill -KILL/-9 php-fpm-master.pid , 強(qiáng)制殺死m(xù)aster進(jìn)程,該信號(hào)不允許中斷/阻塞,此時(shí)master進(jìn)程無法通知回收worker進(jìn)程,所以此時(shí)worker進(jìn)程仍然監(jiān)聽port,仍然可以正常處理http請(qǐng)求.
  • kill -INT/-QUIT/-TERM master pid , stop php-fpm service 信號(hào)被當(dāng)前進(jìn)程樹接收到.也就是說,不僅當(dāng)前進(jìn)程會(huì)收到信號(hào),它的子進(jìn)程也會(huì)收到.
  • kill master pid 發(fā)送SIGTERM信號(hào)到進(jìn)程 信號(hào)可能會(huì)被阻塞,master可以回收worker進(jìn)程.

example.

[sujianhui@dev529 ~]$>ps aux | grep php-fpm
root     17000  0.0  0.0 243220  7208 ?        Ss   17:00   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
sujianh+ 17001  0.0  0.0 245304  7072 ?        S    17:00   0:00 php-fpm: pool www
sujianh+ 17002  0.0  0.0 245304  7072 ?        S    17:00   0:00 php-fpm: pool www
sujianh+ 17069  0.0  0.0 112816   976 pts/3    S+   17:01   0:00 grep --color=auto php-fpm

[sujianhui@dev529 ~]$>sudo kill -USR1 17000
[sujianhui@dev529 ~]$>ps aux | grep php-fpm
root     17000  0.0  0.0 243220  7208 ?        Ss   17:00   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
sujianh+ 17001  0.0  0.0 245304  7072 ?        S    17:00   0:00 php-fpm: pool www
sujianh+ 17002  0.0  0.0 245304  7072 ?        S    17:00   0:00 php-fpm: pool www
sujianh+ 17105  0.0  0.0 112816   972 pts/3    S+   17:01   0:00 grep --color=auto php-fpm


[sujianhui@dev529 ~]$>sudo kill -USR2 17000
[sujianhui@dev529 ~]$>ps aux | grep php-fpm
root     17122  0.0  0.0 243220  7212 ?        Ss   17:01   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
sujianh+ 17123  0.0  0.0 245304  7072 ?        S    17:01   0:00 php-fpm: pool www
sujianh+ 17124  0.0  0.0 245304  7072 ?        S    17:01   0:00 php-fpm: pool www
sujianh+ 17126  0.0  0.0 112816   976 pts/3    S+   17:01   0:00 grep --color=auto php-fpm

[sujianhui@dev529 ~]$>pstree 17122 -a
php-fpm
  ├─php-fpm          
  └─php-fpm          
[sujianhui@dev529 ~]$>sudo kill -INT 17122
[sujianhui@dev529 ~]$>ps aux | grep php-fpm
sujianh+ 17229  0.0  0.0 112816   976 pts/3    S+   17:03   0:00 grep --color=auto php-fpm

so we should use sudo kill -INT master.pid to kill php-fpm service.

nginx的master-worker機(jī)制與fpm大體相同.但是有一個(gè)問題需要注意,使用systemctl啟動(dòng)起來的master被kill以后,worker也會(huì)死掉.

正常啟動(dòng)nginx,kill掉master

[sujianhui@dev0529 sbin]$>which nginx
/usr/sbin/nginx
[sujianhui@dev0529 sbin]$>sudo nginx 
[sujianhui@dev0529 sbin]$>ps aux | grep nginx
root      4562  0.0  0.0  46608  1084 ?        Ss   21:46   0:00 nginx: master process nginx
sujianh+  4563  0.0  0.0  49128  2088 ?        S    21:46   0:00 nginx: worker process
sujianh+  4578  0.0  0.0 112812   972 pts/0    S+   21:46   0:00 grep --color=auto nginx

[sujianhui@dev0529 sbin]$>sudo kill -9 4562
[sujianhui@dev0529 sbin]$>ps aux | grep nginx
sujianh+  4563  0.0  0.0  49128  2088 ?        S    21:46   0:00 nginx: worker process
sujianh+  4612  0.0  0.0 112812   972 pts/0    S+   21:46   0:00 grep --color=auto nginx
[sujianhui@dev0529 sbin]$>kill -9 4563
[sujianhui@dev0529 sbin]$>ps aux | grep nginx
sujianh+  4638  0.0  0.0 112812   972 pts/0    S+   21:47   0:00 grep --color=auto nginx

使用systemctl啟動(dòng)的master被kill掉以后,worker也會(huì)殺掉

[sujianhui@dev0529 sbin]$>systemctl start nginx
[sujianhui@dev0529 sbin]$>ps aux | grep nginx
root      4678  0.0  0.0  46608  1072 ?        Ss   21:47   0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
sujianh+  4679  0.0  0.0  49124  2080 ?        S    21:47   0:00 nginx: worker process
sujianh+  4702  0.0  0.0 112812   972 pts/0    S+   21:47   0:00 grep --color=auto nginx
[sujianhui@dev0529 sbin]$>sudo kill -9 4678
[sujianhui@dev0529 sbin]$>ps aux | grep nginx
sujianh+  4732  0.0  0.0 112812   972 pts/0    S+   21:47   0:00 grep --color=auto nginx

rective run

[sujianhui@dev529 ~]$>kill -l
 1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP
 6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM
16) SIGSTKFLT	17) SIGCHLD	18) SIGCONT	19) SIGSTOP	20) SIGTSTP
21) SIGTTIN	22) SIGTTOU	23) SIGURG	24) SIGXCPU	25) SIGXFSZ
26) SIGVTALRM	27) SIGPROF	28) SIGWINCH	29) SIGIO	30) SIGPWR
31) SIGSYS	34) SIGRTMIN	35) SIGRTMIN+1	36) SIGRTMIN+2	37) SIGRTMIN+3
38) SIGRTMIN+4	39) SIGRTMIN+5	40) SIGRTMIN+6	41) SIGRTMIN+7	42) SIGRTMIN+8
43) SIGRTMIN+9	44) SIGRTMIN+10	45) SIGRTMIN+11	46) SIGRTMIN+12	47) SIGRTMIN+13
48) SIGRTMIN+14	49) SIGRTMIN+15	50) SIGRTMAX-14	51) SIGRTMAX-13	52) SIGRTMAX-12
53) SIGRTMAX-11	54) SIGRTMAX-10	55) SIGRTMAX-9	56) SIGRTMAX-8	57) SIGRTMAX-7
58) SIGRTMAX-6	59) SIGRTMAX-5	60) SIGRTMAX-4	61) SIGRTMAX-3	62) SIGRTMAX-2
63) SIGRTMAX-1	64) SIGRTMAX	

[sujianhui@dev529 ~]$>sudo nginx 
[sudo] password for sujianhui: 
[sujianhui@dev529 ~]$>ps aux | grep nginx
root      3628  0.0  0.0  46600  1052 ?        Ss   09:49   0:00 nginx: master process nginx
sujianh+  3629  0.0  0.0  49096  2056 ?        S    09:49   0:00 nginx: worker process
sujianh+  3637  0.0  0.0 112812   972 pts/0    S+   09:49   0:00 grep --color=auto nginx

[sujianhui@dev529 ~]$>sudo kill -SIGTERM 3628
[sujianhui@dev529 ~]$>ps aux | grep nginx
sujianh+  3744  0.0  0.0 112812   972 pts/0    S+   09:50   0:00 grep --color=auto nginx

[sujianhui@dev529 ~]$>sudo nginx 
[sujianhui@dev529 ~]$>ps aux | grep nginx
root      3766  0.0  0.0  46600  1052 ?        Ss   09:51   0:00 nginx: master process nginx
sujianh+  3767  0.0  0.0  49096  2056 ?        S    09:51   0:00 nginx: worker process
sujianh+  3775  0.0  0.0 112812   972 pts/0    S+   09:51   0:00 grep --color=auto nginx
[sujianhui@dev529 ~]$>sudo kill -9 3766
[sujianhui@dev529 ~]$>ps aux | grep nginx
sujianh+  3767  0.0  0.0  49096  2056 ?        S    09:51   0:00 nginx: worker process
sujianh+  3799  0.0  0.0 112812   972 pts/0    S+   09:51   0:00 grep --color=auto nginx

apache prefork

總結(jié)

到此這篇關(guān)于php7中停止php-fpm服務(wù)的文章就介紹到這了,更多相關(guān)php7停止php-fpm服務(wù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 教你在header中隱藏php的版本信息

    教你在header中隱藏php的版本信息

    本文教大家如何在header信息中隱藏PHP的版本信息,這樣修改后對(duì)于大家的php程序會(huì)更加安全,有需要的可以參考學(xué)習(xí)。
    2016-08-08
  • php的無刷新操作實(shí)現(xiàn)方法分析

    php的無刷新操作實(shí)現(xiàn)方法分析

    這篇文章主要介紹了php的無刷新操作實(shí)現(xiàn)方法,結(jié)合實(shí)例形式總結(jié)分析了PHP無刷新操作常見原理、實(shí)現(xiàn)技巧與注意事項(xiàng),需要的朋友可以參考下
    2020-02-02
  • php繪制圓形的方法

    php繪制圓形的方法

    這篇文章主要介紹了php繪制圓形的方法,詳細(xì)分析了php繪制圖形的基本步驟與繪制圓形的實(shí)現(xiàn)方法,需要的朋友可以參考下
    2015-01-01
  • php調(diào)用自己java程序的方法詳解

    php調(diào)用自己java程序的方法詳解

    這篇文章主要介紹了php調(diào)用自己java程序的方法,較為詳細(xì)的分析了php基于第三方j(luò)ar包調(diào)用java程序以及使用dll動(dòng)態(tài)鏈接庫(kù)文件擴(kuò)展進(jìn)行java調(diào)用兩種方法,需要的朋友可以參考下
    2016-05-05
  • php中動(dòng)態(tài)調(diào)用函數(shù)的方法

    php中動(dòng)態(tài)調(diào)用函數(shù)的方法

    這篇文章主要介紹了php中動(dòng)態(tài)調(diào)用函數(shù)的方法,實(shí)例分析了php動(dòng)態(tài)函數(shù)的實(shí)現(xiàn)原理與具體實(shí)現(xiàn)步驟,需要的朋友可以參考下
    2015-03-03
  • 使用Zttp簡(jiǎn)化Guzzle 調(diào)用

    使用Zttp簡(jiǎn)化Guzzle 調(diào)用

    在 PHP 的項(xiàng)目中,如果你需要通過代碼來發(fā)起 HTTP 請(qǐng)求,相信很多人對(duì) GuzzleHttp 這個(gè) Package 很熟悉,然而其實(shí)在使用 Guzzle 的時(shí)候,我們依然可以做得更簡(jiǎn)便一點(diǎn)的,下面我們就來看下今天的主角--Zhttp
    2017-07-07
  • php禁用cookie后session設(shè)置方法分析

    php禁用cookie后session設(shè)置方法分析

    這篇文章主要介紹了php禁用cookie后session設(shè)置方法,分析了php相關(guān)配置文件的功能與設(shè)置方法,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2016-10-10
  • php使用GD2繪制幾何圖形示例

    php使用GD2繪制幾何圖形示例

    這篇文章主要介紹了php使用GD2繪制幾何圖形,結(jié)合實(shí)例形式分析了GD2繪圖所涉及的常用函數(shù)與具體使用技巧,需要的朋友可以參考下
    2017-02-02
  • 使用Huagepage和PGO來提升PHP7的執(zhí)行性能

    使用Huagepage和PGO來提升PHP7的執(zhí)行性能

    這篇文章主要介紹了使用Huagepage和PGO來提升PHP7的執(zhí)行性能的相關(guān)方案,來自于注明的PHP開發(fā)組成員Laruence的相關(guān)研究,需要的朋友可以參考下
    2015-11-11
  • ThinkPHP php 框架學(xué)習(xí)筆記

    ThinkPHP php 框架學(xué)習(xí)筆記

    花了兩個(gè)多鐘在看 ThinkPHP 框架,不想太過深入的知道它的所有高深理論。單純想知道怎么可以用起來,可以快捷的搭建一個(gè)網(wǎng)站。所以是有選擇的看,二個(gè)鐘后還是一頭霧水。于是決定改變學(xué)習(xí)策略,上官方論壇看其它高人寫的民間教程,果然比官方的通俗易懂多了。
    2009-10-10

最新評(píng)論

正安县| 沾化县| 田阳县| 建水县| 万州区| 淅川县| 蒲江县| 抚顺市| 沙雅县| 临洮县| 奎屯市| 抚顺县| 桃园市| 古田县| 林州市| 岑溪市| 克什克腾旗| 平遥县| 鄂托克前旗| 扶余县| 古交市| 永德县| 项城市| 达尔| 阳谷县| 奉贤区| 长寿区| 阳新县| 阳高县| 定南县| 尉犁县| 景东| 浙江省| 富民县| 德惠市| 丰顺县| 谷城县| 江北区| 桃园市| 耿马| 邮箱|