查看Nginx安裝目錄
使用命令 which nginx
和 whereis nginx
午绳。 前者只適用于軟件的安裝目錄被添加進(jìn)了系統(tǒng) Path 的的情況置侍。
查看 nginx 配置文件所在目錄
使用命令 find / | grep nginx.conf
。其作用為:查找 (find
) ,在系統(tǒng)根目錄 (/
) 及其子目錄下蜡坊,所有名為 nginx.conf
的文件杠输。
執(zhí)行結(jié)果如下:
/usr/xxxx/www-servers/nginx/files/nginx.conf
/etc/nginx/nginx.conf
我們得到兩條結(jié)果,說明存在兩個 Nginx 配置文件秕衙。第二步蠢甲,需要確認(rèn)當(dāng)前運(yùn)行的服務(wù)器使用的是哪個配置文件。
確認(rèn) Nginx 啟動的是哪個配置文件
使用命令 ps -ef | grep nginx
据忘。其作用為:查看正在運(yùn)行的名叫 nginx
的進(jìn)程 (ps
)鹦牛。
-e
: 顯示所有進(jìn)程。
-f
: 全格式勇吊。
執(zhí)行結(jié)果如下:
root 22524 1 0 06:47 ? 00:00:00 nginx: master process nginx -c /etc/nginx/nginx.conf
nginx 22525 22524 0 06:47 ? 00:00:00 nginx: worker process
root 22634 22471 0 07:16 pts/1 00:00:00 grep --colour=auto nginx
從第一行末尾可以看到曼追,當(dāng)前啟動的是 /etc/nginx/nginx.conf
。
退出和停止 Nginx
nginx -s quit
和 nginx -s stop
汉规。
啟動 Nginx
nginx -c /etc/nginx/nginx.conf
礼殊。
注:文中提到的命令在 linux 中非常實(shí)用,可用于查找任意軟件和文件针史。