修改Nginx或者nginx.conf配置文件时我们需要找到Nginx的安装目录,那么如何准确定位Nginx安装目录和nginx.conf配置文件目录呢?新手站长网分享一个命令ps -ef | grep nginx即可搞定!
查看nginx安装目录
执行命令:ps -ef | grep nginx
[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
查看nginx.conf配置文件目录
执行命令:nginx -t
[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配置文件目录。
Nginx启动/重启/停止命令
Nginx启动命令:service nginx start
Nginx重启命令:service nginx restart
Nginx停止命令:service nginx stop
阿里云官方活动:https://t.aliyun.com/U/FzmsXA
腾讯云官方活动:https://curl.qcloud.com/oRMoSucP
