我意外删除了 Nginx 站点的配置文件/etc/nginx/sites-avialable
。/etc/nginx/sites-enabled
包含指向已删除文件的符号链接。尽管如此(?),该网站仍在运行。是否有可能恢复该文件(因为 Nginx 仍在使用该配置)?
答案1
由于@Ben L 确认它运行良好,我们就将其作为答案。
https://serverfault.com/questions/361421/dump-nginx-config-from-running-process
您需要安装 gdb 来转储正在运行的进程的内存区域。
调整完 pid 后运行此脚本#
# Set pid of nginx master process here pid=8192
# generate gdb commands from the process's memory mappings using awk cat /proc/$pid/maps | awk '$6 !~ "^/" {split ($1,addrs,"-"); print "dump memory mem_" addrs[1] " 0x" addrs[1] " 0x" addrs[2] ;}END{print "quit"}' > gdb-commands
# use gdb with the -x option to dump these memory regions to mem_* files gdb -p $pid -x gdb-commands
# look for some (any) nginx.conf text grep worker_connections mem_* grep server_name mem_*