1.1 终极方法
以编译安装的nginx为例
[root@node21 ~]# nginx -h
nginx version: nginx/1.18.0
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /data/nginx/nginx-1.18.0/) <== 有默认值的哈
-c filename : set configuration file (default: conf/nginx.conf) <== 有默认值的哈
-g directives : set global directives out of configuration file
从哪里可以看出来它是编译安装的呢,就是-c参数的默认值不是一个完整的路径,那么它就是编译安装的。
以yum安装的为例
[root@node21 ~]# nginx -h
nginx version: nginx/1.16.0
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-T : test configuration, dump it and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /etc/nginx/) <== 有默认值的哈
-c filename : set configuration file (default: /etc/nginx/nginx.conf) <== 有默认值的哈
-g directives : set global directives out of configuration file
从哪可以看出来它是yum安装(非编译安装)的呢,就是-c参数的默认值它是一个完整的路径
1.2 常规的方法
用ps -ef来查看,不一定准
#### 用ps -ef|grep nginx查看的结果如下
[root@node21 ~]#
[root@node21 ~]# ps -ef|grep nginx
root 24180 1 0 02:32 ? 00:00:00 nginx: master process /data/nginx/nginx/sbin/nginx
www 24181 24180 0 02:32 ? 00:00:00 nginx: worker process
root 24186 23801 0 02:33 pts/1 00:00:00 grep --color=auto nginx
#### 说明
01:这样就可以直接看到nginx是安装在/data/nginx目录下的
02:它的启动方式是用/data/nginx/nginx/sbin/nginx来启动的(不管是脚本里面写的,还是手动执行的)
03:但也不一定准,因为可能人为进入到sbin目录下用./nginx来启动;如下所示
[root@node21 ~]# ps -ef|grep nginx
root 24209 1 0 02:35 ? 00:00:00 nginx: master process nginx
www 24210 24209 0 02:35 ? 00:00:00 nginx: worker process
root 24212 23801 0 02:35 pts/1 00:00:00 grep --color=auto nginx
查看nginx -V来查看
#### 那么如何查看nginx的安装位置呢?
[root@node21 ~]#
[root@node21 ~]# nginx -V # 用nginx的-V参数
nginx version: nginx/1.18.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/data/apps/nginx-1.18.0 --user=www --group=www --with-stream
[root@node21 ~]#
[root@node21 ~]# which nginx # 查看nginx命令在什么位置
/data/nginx/nginx/sbin/nginx