Nginx - 2877206/docs GitHub Wiki

install

安装教程

1.下载对应当前系统版本的nginx包(package)

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

2.建立nginx的yum仓库

rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

3.下载并安装nginx

yum install nginx

4.启动nginx服务

systemctl start nginx

5.配置

默认的配置文件在 /etc/nginx/conf.d/default.co 路径下,使用该配置已经可以正确地运行nginx;如需要自定义,修改其下的 nginx.conf 等文件即可。

Web文件**/usr/share/nginx/html**。

6.测试

在浏览器地址栏中输入部署nginx环境的机器的IP,如果一切正常,应该能看到如下字样的内容。

yum install nginx

服务命令

systemctl start nginx

service nginx restart

systemctl status nginx.service

配置

/etc/nginx/conf.d

日志

/var/log/nginx/log/host.access.log

测试

curl http://localhost/index.html

启用nginx status状态详解

http://www.ttlsa.com/nginx/nginx-status-detail/

  1. 启用nginx status配置

在默认主机里面加上location或者你希望能访问到的主机里面。

server {

`listen  *:80 default_server;`

`server_name _;`

`location /ngx_status `

`{`

    `stub_status on;`

    `access_log off;`

    `#allow 127.0.0.1;`

    `#deny all;`

`}`

}

  1. 重启nginx

请依照你的环境重启你的nginx

service nginx restart

service nginx restart

  1. 打开status页面

curl http://127.0.0.1/ngx_status

Active connections: 11921

server accepts handled requests

11989 11989 11991

Reading: 0 Writing: 7 Waiting: 42

  1. nginx status详解

active connections – 活跃的连接数量

server accepts handled requests — 总共处理了11989个连接 , 成功创建11989次握手, 总共处理了11991个请求

reading — 读取客户端的连接数.

writing — 响应数据到客户端的数量

waiting — 开启 keep-alive 的情况下,这个值等于 active – (reading+writing), 意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接.