修改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