首页 > 后端开发 > php教程 > ngx_lua实现重启php

ngx_lua实现重启php

WBOY
发布: 2016-07-29 08:58:47
原创
1029 人浏览过

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

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板