Rumah > pembangunan bahagian belakang > tutorial php > ngx_lua实现重启php

ngx_lua实现重启php

WBOY
Lepaskan: 2016-07-29 08:58:47
asal
1029 orang telah melayarinya

nginx

<code>         location /reload {
             default_<span>type</span>  text/html;
             content_by_lua_file reload_php.lua;
         }</code>
Salin selepas log masuk

lua

<code><span>local</span> args = ngx.req.get_query_args();
<span>local</span> uid = args[<span>"uid"</span>]
<span>local</span> key = args[<span>"key"</span>]
<span>local</span> uidmd5 = string.sub(ngx.md5(uid),<span>0</span>,<span>12</span>)

<span>if</span> key ~= uidmd5 then
     ngx.<span>say</span>(<span>"Hey man, you can't do this."</span>)
     ngx.<span>exit</span>(<span>200</span>)
<span>else</span><span>local</span> f = io.<span>open</span>(<span>"reload_access.log"</span> , <span>"a"</span>)
     <span>time</span> = os.date(<span>"<span>%c</span>"</span>,os.<span>time</span>())
     f:<span>write</span>(uid .. <span>" "</span> .. <span>time</span>)
     f:<span>close</span>()
     <span>local</span> command =<span>"sh reload_php.sh"</span>
     --<span>local</span> command =<span>"/bin/kill -USR2 `cat /var/run/php-fpm.pid`"</span>
     type = os.execute(command)
     <span>if</span> type == <span>0</span> then
          ngx.<span>print</span>(<span>"ok"</span>)
          ngx.<span>exit</span>(<span>200</span>)
     <span>else</span>
     ngx.<span>print</span>(<span>"error"</span>)
     f:<span>write</span>(<span>" error"</span>)
     f:<span>close</span>()
     ngx.<span>exit</span>(<span>200</span>)
     end
end</code>
Salin selepas log masuk

shell

<code><span>#!/bin/bash</span><span>#</span><span>#reload php-fpm</span><span>#</span><span>#kill -USR2 `cat /var/run/php-fpm.pid`</span>
killall php-fpm
/php/sbin/php-fpm -c /etc/php.ini -y /php/etc/php-fpm.conf
<span>echo</span><span>" ok"</span> >> /reload_access.log</code>
Salin selepas log masuk

写这玩的,大神请指正。

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

以上就介绍了ngx_lua实现重启php,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan