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

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

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

Linux環境下,怎麼確定Nginx是以那個config檔案啟動的?
[[email protected] ~]# 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及對應目錄:
[[email protected] ~]# 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

還可以用以下兩個命令,找安裝的路徑
[[email protected] ~]# 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的啟動方式了。
[

[email protected] ~]# 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 的版本,編譯器版本和配置引數。
[

[email protected] ~]# /usr/sbin/nginx -v
nginx version: nginx/1.8.0

===================================
檢視linux系統版本命令
[[email protected] ~]# cat /proc/version
Linux version 4.1.5-x86_64-linode61 ([email protected]) (gcc version 4.7.2 (Debian 4.7.2-5) ) #7 SMP Mon Aug 24 13:46:31 EDT 2015
[[email protected] ~]# 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