Heim >Backend-Entwicklung >PHP-Tutorial >ngx_lua实现重启php

ngx_lua实现重启php

WBOY
WBOYOriginal
2016-07-29 08:58:471029Durchsuche

nginx

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

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>

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>

写这玩的,大神请指正。

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

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn