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

1、查看nginx安装目录

输入命令

# ps  -ef | grep nginx

返回结果包含安装目录

root      2662     1  0 07:12 ?        00:00:00 nginx: master process /usr/sbin/nginx

2、查看nginx.conf配置文件目录

输入命令

# nginx -t

返回结果包含配置文件目录

nginx: the configuration file /etc/nginx/nginx.conf syntax is ok

nginx: configuration file /etc/nginx/nginx.conf test is successful

3、启动nginx服务

[root@localhost ~]# nginx安装目录 -c nginx.conf配置文件目录

参数 “-c” 指定了配置文件的路径,如果不加 “-c” 参数,Nginx 会默认加载其安装目录的 conf 子目录中的 nginx.conf 文件。

 

 

 


 

查找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


原文链接:https://www.cnblogs.com/zdz8207/p/CentOS-nginx-yum.html

转载于:https://www.cnblogs.com/qianjilou/p/9550639.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要查看Linux上的nginx安装目录,可以按照以下步骤进行操作: 1. 首先,可以查找nginx.conf文件所在的目录。nginx.conf文件一般位于nginx安装目录下的conf子目录。可以使用命令`find / -name nginx.conf`来查找文件名为nginx.conf的文件。这将在整个文件系统中搜索nginx.conf文件,并显示其所在的路径。\[3\] 2. 另外,如果是从源代码编译安装nginx,还可以查看编译时的配置参数。可以使用命令`cat ./configure.out | grep 'configure arguments'`来查看编译时的配置参数,其中包括nginx安装目录。\[1\] 3. 最后,可以使用命令`/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf`来检测新的配置文件,并指定nginx.conf配置文件的路径。这个命令将检查配置文件的语法是否正确,并显示nginx安装目录。\[2\] 综上所述,你可以通过查找nginx.conf文件的路径、查看编译时的配置参数或者检测新的配置文件来获取nginx安装目录。 #### 引用[.reference_title] - *1* [linux查看nginx安装路径](https://blog.csdn.net/qq_44633541/article/details/130444890)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Linux 查看 nginx 安装目录和配置文件路径](https://blog.csdn.net/qq_39595769/article/details/121139787)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值