nginx使用-如何在linu查询Nginx安装目录和nginx.conf配置文件目录

修改Nginx或者nginx.conf配置文件时我们需要找到Nginx的安装目录,那么如何准确定位Nginx安装目录和nginx.conf配置文件目录呢

查看nginx安装目录

在终端执行命令:ps -ef | grep nginx

结果如下:

[admin@iZuf65vm84pty2g1psl4s4Z ~]$ ps -ef | grep nginx
root      9426     1  0  2018 ?        00:00:06 nginx: master process /alidata1/app/tengine/sbin/nginx -c /alidata1/conf/tengine/nginx.conf
nginx    23237  9426  0 00:00 ?        00:00:22 nginx: worker process
nginx    23238  9426  0 00:00 ?        00:00:22 nginx: worker process
nginx    23239  9426  0 00:00 ?        00:00:21 nginx: worker process
nginx    23240  9426  0 00:00 ?        00:00:21 nginx: worker process
admin    30596 30571  0 20:16 pts/1    00:00:00 grep --color=auto nginx

可以看到nginx的安装路径为:/alidata1/app/tengine/sbin/nginx

查看nginx.conf配置文件目录

执行: nginx -t
接口如下:

nginx -t
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful

nginx 使用的配置文件就在这里 usr/local/etc/nginx/nginx.conf
ps:
如果在执行nginx -t 出现 nginx: command not found
就使用第一步找的nginx 的安装目录来执行

/alidata1/app/tengine/sbin/nginx  -t

缠看nginx版本号

nginx -v
  • -v 显示 nginx 的版本。

  • -V 显示 nginx 的版本,编译器版本和配置参数。

使用vim 编辑配置文件

使用vim编辑保存后使用 Nginx重启命令:service nginx restart 使配置文件生效

nginx 常用命令

Nginx启动命令:service nginx start
Nginx重启命令:service nginx restart
Nginx停止命令:service nginx stop

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值