Linux 服务器上如何查找 nginx 的安装路径?

刚刚需要修改网站的 nginx 伪静态配置,于是登录到 VPS 主机,可是 nginx 的安装目录不记得了。其实就算记得一次,下次也会忘记。怎么样快速查找?

最简单的方法是用 ps -ef | grep nginx 命令:

[root@HQW-Aliyun ~]# ps -ef | grep nginx
root 908 1 0 Aug09 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
www 910 908 0 Aug09 ? 00:21:28 nginx: worker process
root 9586 9279 0 11:33 pts/0 00:00:00 grep nginx

还可以使用更简单的 nginx -t 命令:
[root@Aliyun ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful