首先进入官网 ,详细安装在http://nginx.org/en/linux_packages.html

 

1、首先添加一下nginx的官网yum源,命令如下:

vim /etc/yum.repos.d/nginx.repo 

进去加入以下内容,根据你自己的系统选择:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

然后直接yum安装即可

yum install nginx

然后安装完成后:

nginx -v可以查看当前版本。

nginx -V可以查看编译的这些参数

whereis nginx 可以查看nginx的默认安装目录

yum安装最新稳定版本nginx_配置文件

以下是Nginx的默认路径:

(1) Nginx配置路径:/etc/nginx/

(2) PID目录:/var/run/nginx.pid

(3) 错误日志:/var/log/nginx/error.log

(4) 访问日志:/var/log/nginx/access.log

(5) 默认站点目录:/usr/share/nginx/html

事实上,只需知道Nginx配置路径,其他路径均可在/etc/nginx/nginx.conf 以及/etc/nginx/conf.d/default.conf 中查询到

nginx相关的验证命令及启动命令

[root@localhost yum.repos.d]# nginx                    
[root@localhost yum.repos.d]# nginx -t                   
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@localhost yum.repos.d]# nginx -s reload  

nginx启动:

1)首先利用配置文件启动nginx:

如果你的nginx配置文件在/etc/nginx/nginx.conf,启动nginx就可以nginx -c /etc/nginx/nginx.conf

重启服务: service nginx restart

nginx信号

nginx -s 是给nginx发信号
nginx -s stop 立即停止
nginx -s quit 优雅停止
nginx -s reload重读配置文件

nginx -t  测试命令