欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

ngx_lua实现重启php

程序员文章站 2022-05-14 21:51:22
...
nginx
         location /reload {
             default_type  text/html;
             content_by_lua_file reload_php.lua;
         }

lua

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

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

shell

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

写这玩的,大神请指正。

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

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