400-1513-886

全国统一服务热线

系统运维

查找nginx安装的路径以及相关安装操作命令

发布时间:2019-07-22 10:11:03 945 次

查找nginx安装的路径以及相关安装操作命令

Linux环境下,怎么确定Nginx是以那个config文件启动的? 
[root@localhost ~]# ps -ef | grep nginx
root 21196 1 0 23:40 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
nginx 21197 21196 0 23:40 ? 00:00:00 nginx: worker process
root 21199 20993 0 23:42 pts/0 00:00:00 grep --color=auto nginx
------------------------------------
检查是否已经安装有nginx及对应目录:
[root@localhost ~]# find /|grep nginx.conf
/etc/nginx/conf.d
/etc/nginx/conf.d/example_ssl.conf
/etc/nginx/conf.d/default.conf
/etc/nginx/nginx.conf
----------------------------------
还可以用以下两个命令,找安装的路径
[root@localhost ~]# netstat -tnlp|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 21196/nginx: master
然后看到一行记录,复制最后的一个数据(进程ID)
ps -aux |grep 进程ID
就可以看到nginx的启动方式了。
[root@localhost ~]# ps -aux |grep 21196
root 21196 0.0 0.0 48044 924 ? Ss 23:40 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
root 21204 0.0 0.2 112648 2320 pts/0 S+ 23:45 0:00 grep --color=auto 21196

--------------------------------
查看服务器上安装的nginx版本号,主要是通过ngix的-v或-V选项
Linux下查看Nginx安装目录、版本号信息?
-v 显示 nginx 的版本。
-V 显示 nginx 的版本,编译器版本和配置参数。
[root@localhost ~]# /usr/sbin/nginx -v
nginx version: nginx/1.8.0

===================================
查看linux系统版本命令
[root@localhost ~]# cat /proc/version
Linux version 4.1.5-x86_64-linode61 (maker@build) (gcc version 4.7.2 (Debian 4.7.2-5) ) #7 SMP Mon Aug 24 13:46:31 EDT 2015
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.0.1406 (Core)

===================================
Ubuntu下安装nginx,直接apt-get install nginx就行了

CentOS 下安装nginx:
centos7系统库中默认是没有nginx的rpm包的,所以我们自己需要先更新下rpm依赖库
(1)使用yum安装nginx需要包括Nginx的库,安装Nginx的库
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
rpm包的安装:
1.安装一个包
# rpm -ivh
2.升级一个包,没安装过的不能使用升级命令
# rpm -Uvh
3.移走一个包
# rpm -e

安装准备依赖lib库
yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

(2)使用下面命令安装nginx
#yum install nginx

(3)启动Nginx
#service nginx start

#systemctl start nginx.service
(4)重启nginx
service nginx restart

扫码进入小程序

公司名称:广州统天网络科技有限公司

公司地址:广州市白云区石井镇潭村水闸街6号

公司电话:400-1513-886

公司邮箱:info@tongtian.tech