一、查看nginx安裝目錄html
輸入命令node
# ps -ef | grep nginxlinux
返回結果包含安裝目錄nginx
root 2662 1 0 07:12 ? 00:00:00 nginx: master process /usr/sbin/nginxc++
二、查看nginx.conf配置文件目錄centos
輸入命令服務器
# nginx -t 返回結果包含配置文件目錄
nginx: the configuration file /etc/nginx/nginx.conf syntax is oktcp
nginx: configuration file /etc/nginx/nginx.conf test is successfului
三、啓動nginx服務centos7
[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