Maison >développement back-end >tutoriel php >ngx_lua实现重启php

ngx_lua实现重启php

WBOY
WBOYoriginal
2016-07-29 08:58:471030parcourir

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教程有兴趣的朋友有所帮助。

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn