如何查询Nginx安装目录和nginx.conf配置文件目录

2018年4月21日14:56:35服务器教程如何查询Nginx安装目录和nginx.conf配置文件目录已关闭评论9,421 views2

修改Nginx或者nginx.conf配置文件时我们需要找到Nginx的安装目录,那么如何准确定位Nginx安装目录和nginx.conf配置文件目录呢?新手站长网分享一个命令ps -ef | grep nginx即可搞定!文章源自新手站长网-https://www.xinshouzhanzhang.com/nginxconflujing.html

查看nginx安装目录

执行命令:ps -ef | grep nginx文章源自新手站长网-https://www.xinshouzhanzhang.com/nginxconflujing.html

[root@xinshouzhanzhang ~]# ps  -ef | grep nginx
root      4371  4351  0 13:41 pts/2    00:00:00 grep --color=auto nginx
root     30765     1  0 13:20 ?        00:00:00 nginx: master process /www/server/nginx/sbin/nginx -c /www/server/nginx/conf/nginx.conf
www      30766 30765  0 13:20 ?        00:00:00 nginx: worker process
www      30767 30765  0 13:20 ?        00:00:00 nginx: cache manager process

我们看到nginx的安装路径为:/www/server/nginx文章源自新手站长网-https://www.xinshouzhanzhang.com/nginxconflujing.html

查看nginx.conf配置文件目录

执行命令:nginx -t文章源自新手站长网-https://www.xinshouzhanzhang.com/nginxconflujing.html

[root@xinshouzhanzhang ~]# nginx -t
nginx: the configuration file /www/server/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /www/server/nginx/conf/nginx.conf test is successful

综上,使用ps -ef | grep nginx命令可以快速查看Nginx的安装路径,使用nginx -t可以查看nginx.conf配置文件目录。文章源自新手站长网-https://www.xinshouzhanzhang.com/nginxconflujing.html

Nginx启动/重启/停止命令

Nginx启动命令:service nginx start
Nginx重启命令:service nginx restart
Nginx停止命令:service nginx stop文章源自新手站长网-https://www.xinshouzhanzhang.com/nginxconflujing.html