一.先找到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配置
原文:https://www.cnblogs.com/liuwei-book/p/12176615.html