阿里云主机

万维景盛

万维景盛官网
CENTOS系统下怎样查找nginxd配置文件的文件夹路径?

如果你操作一台客户的服务器,需要找到nginx的配置文件,那么完全陌生的环境,怎样快速找到nginx应用的安装位置和路径呢?万维景盛工程师为您分享定位方法:

登录SSH,然后输入#后面的LINUX命令代码:

ps -ef | grep nginx

服务器返回以下信息:

root      1382     1  0 16:42 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

www       1383  1382  0 16:42 ?        00:00:00 nginx: worker process

www       1384  1382  0 16:42 ?        00:00:00 nginx: worker process

root      2167  2145  0 16:52 pts/0    00:00:00 grep 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


< 购物车 > 会员 客服 充值 工单
Top

客服热线

010-80253326

18610695105

客服QQ

请拨总机 010-80253326

咨询售后问题建议 提交工单