如何正確找到nginx的配置文件位置


一.先找到nginx可執行文件的路徑

  a。程序正在運行中:

# ps -ef | grep nginx

root 771 1 0 10:36 ? 00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;  # 看到mster進程,可以直接看到可執行文件路徑
www-data 772 771 0 10:36 ? 00:00:00 nginx: worker process
www-data 773 771 0 10:36 ? 00:00:00 nginx: worker process
root 3282 3233 0 15:58 pts/3 00:00:00 grep --color=auto nginx  # 忽略這個查詢進程

  b.程序沒有運行:

# whereis nginx   // 查看軟件安裝路徑

nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
# which nginx // 查詢運行文件所在路徑

/usr/sbin/nginx

   c .其他查詢方法

rpm包安裝的,可以用rpm -qa | grep “軟件或者包的名字”查詢;
#
rpm -qa | grep nginx
yum方法安裝的,可以用yum list installed查找;
#
yum list installed

 

二.在通過nginx自身的功能找到當前nginx對應的配置文件路徑

#/usr/sbin/nginx -t   # conf_path

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok  # 檢測nginx.conf配置文件語法正確
nginx: configuration file /etc/nginx/nginx.conf test is successful  # 測試nginx.conf配置文件執行正確

 

三》在/etc/nginx/nginx.conf 配置文件中設置nginx配置

四:查看MySQL的配置文件路徑

首先先看看你的mysql在哪,通過which命令which mysql
顯示出目錄比如我的是這個 /usr/bin/mysql
接下來就可以針對這個目錄通過一些命令查看配置文件在哪了,如下
/usr/bin/mysql --verbose --help | grep -A 1 'Default options'
然后在下面會出現一些信息
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
這個信息的意思是:
服務器首先讀取的是/etc/mysql/my.cnf文件,如果前一個文件不存在則繼續讀/etc/my.cnf文件,如若還不存在便會去讀~/.my.cnf文件

原文鏈接:https://blog.csdn.net/OMars/article/details/88086838

/usr/bin/mysql --verbose --help | grep -A 1 'Default options'


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM