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)
else
local 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
写这玩的,大神请指正。