欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

linux誤刪nginx.conf文件恢復(fù)方式

 更新時間:2024年01月13日 08:37:56   作者:dounine  
這篇文章主要介紹了linux誤刪nginx.conf文件恢復(fù)方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

當(dāng)你不小心誤刪或者錯誤操作導(dǎo)致nginx.conf文件丟失,而且nginx處于在住運行的狀態(tài),在這種情況下我們就可以在內(nèi)存中獲取配置文件。

1.獲取nginx進程pid

ps -ef | grep nginx

你會得到如下輸出,找到master的pid

root     19812     1  0 7月14 ?       00:00:00 nginx: master process /usr/sbin/nginx
nginx    19813 19812  0 7月14 ?       00:00:26 nginx: worker process
nginx    19814 19812  0 7月14 ?       00:00:33 nginx: worker process
nginx    19815 19812  0 7月14 ?       00:01:15 nginx: worker process
nginx    19816 19812  0 7月14 ?       00:00:55 nginx: worker process
nginx    19817 19812  0 7月14 ?       00:00:04 nginx: cache manager process
root     26171 12446  0 12:56 pts/0    00:00:00 grep --color=auto nginx

如上所示,nginx的主要進程pid為19812

2.查找內(nèi)存映射

安裝gdb工具

yum install gdb -y

接下來我們需要檢查進程正在使用哪些內(nèi)存映射

cat /proc/19812/maps | grep heap
[root@loghub-server tmp]# cat /proc/19812/maps | grep heap
55e0e6760000-55e0e69c2000 rw-p 00000000 00:00 0                          [heap]

可以看到有2處地方,我們只需要關(guān)注heap部分。內(nèi)存位于55e0e6760000-55e0e69c2000之間。

3.轉(zhuǎn)儲堆

然后需要轉(zhuǎn)儲堆

gdb -p 19812

你會得到一個(gdb)提示?,F(xiàn)在在這個提示下使用我們之前記下的地址,地址前需要加0x

(gdb) dump memory /tmp/nginx-memory 0x55e0e6760000 0x55e0e69c2000

4.從轉(zhuǎn)儲中獲取字符串?dāng)?shù)據(jù)

strings  /tmp/nginx-memory > /tmp/nginx-memory.str

5.查找 Nginx 配置

現(xiàn)在有了內(nèi)存轉(zhuǎn)儲。大多數(shù)配置都會有http {一行,現(xiàn)在可以測試下/tmp/nginx-memory.str

grep -A 20 "http {" /tmp/nginx-memory.str
[root@loghub-server tmp]# grep -A 50 "http {" /tmp/nginx-memory.str 
http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;
    #proxy_temp_path  /etc/nginx/temp_dir;
    #proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=imgcache:100m inactive=1d max_size=1g;
    #proxy_cache_path /etc/nginx/cache_dir levels=1:2 keys_zone=imgcache:500m max_size=1g inactive=1d use_temp_path=off;
    proxy_cache_path /etc/nginx/conf.d/cache levels=1:2 keys_zone=my_zone:100m inactive=3600s max_size=1g;

自己復(fù)制出來或者修改下格式之類的,就可以了。

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • CentOS7 LNMP+phpmyadmin環(huán)境搭建 第二篇LNMP環(huán)境搭建教程

    CentOS7 LNMP+phpmyadmin環(huán)境搭建 第二篇LNMP環(huán)境搭建教程

    這篇文章主要為大家詳細介紹了CentOS7 LNMP+phpmyadmin環(huán)境搭建,第二篇LNMP環(huán)境搭建教程,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-07-07
  • 13個實用的Apache Rewrite重寫規(guī)則

    13個實用的Apache Rewrite重寫規(guī)則

    這篇文章主要介紹了13個實用的Apache Rewrite重寫規(guī)則,需要的朋友可以參考下
    2014-03-03
  • CentOS 7 安裝Chrome瀏覽器的方法

    CentOS 7 安裝Chrome瀏覽器的方法

    這篇文章主要介紹了CentOS 7 安裝Chrome瀏覽器的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-12-12
  • 淺談Linux中的chattr與lsattr命令

    淺談Linux中的chattr與lsattr命令

    下面小編就為大家?guī)硪黄獪\談Linux中的chattr與lsattr命令。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-12-12
  • Linux alias命令編寫

    Linux alias命令編寫

    這篇文章主要介紹了Linux alias命令編寫,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-08-08
  • 詳解阿里云Linux啟動tomcat并能外網(wǎng)訪問

    詳解阿里云Linux啟動tomcat并能外網(wǎng)訪問

    本篇文章主要介紹了詳解阿里云Linux啟動tomcat并能外網(wǎng)訪問,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-03-03
  • Ubuntu解決火狐瀏覽器無法同步書簽的問題【推薦】

    Ubuntu解決火狐瀏覽器無法同步書簽的問題【推薦】

    最近在ubuntu系統(tǒng)中使用自帶的firefox瀏覽器,發(fā)現(xiàn)有寫問題,添加書簽功能無法使用,下面小編給大家?guī)砹薝buntu解決火狐瀏覽器無法同步書簽的問題,感興趣的朋友跟隨腳本之家小編一起看看吧
    2018-06-06
  • 101個腳本之建立linux回收站的腳本

    101個腳本之建立linux回收站的腳本

    眾所周知,linux是沒有回收站的,一些人很害怕刪錯東西(有經(jīng)驗的linux管理員極少范這錯誤),個人不建議回收站,而應(yīng)該是培養(yǎng)個人的安全意識。有點小跑題
    2016-08-08
  • CentOS6.5下Tomcat7 Nginx Redis配置步驟教程詳解

    CentOS6.5下Tomcat7 Nginx Redis配置步驟教程詳解

    這篇文章主要介紹了CentOS6.5下Tomcat7 Nginx Redis配置步驟,本文給大家介紹的非常詳細,具有參考借鑒價值,需要的朋友可以參考下
    2016-10-10
  • Linux中的LUN、磁盤、LVM和文件系統(tǒng)映射使用

    Linux中的LUN、磁盤、LVM和文件系統(tǒng)映射使用

    這篇文章主要介紹了Linux中的LUN、磁盤、LVM和文件系統(tǒng)映射使用方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-02-02

最新評論