1. 程式人生 > >查找nginx安裝的路徑以及相關安裝操作命令

查找nginx安裝的路徑以及相關安裝操作命令

cor clas 顯示 操作 nginx安裝 行記錄 font nginx版本號 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

查找nginx安裝的路徑以及相關安裝操作命令