#安装环境准备
[root@E-host tools]# yum install pcre* openssl* -y
[root@E-host tools]# useradd nginx -s /sbin/nologin -M
[root@E-host tools]# ./configure --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx
[root@E-host tools]# make
[root@E-host tools]# make install
#启动
[root@E-host tools]# /application/nginx/sbin/nginx -t
[root@E-host tools]# /application/nginx/sbin/nginx
#关闭防火墙
[root@E-host tools]#chkconfig iptables off
[root@E-host tools]# /etc/init.d/iptables stop
[root@E-host tools]# setenforce 0
[root@E-host tools]# cat /etc/selinux/config|grep SELINUX=disabled
#配置文件
/application/nginx/conf/nginx.conf
[root@E-host conf]# egrep -v "#|^$" conf/nginx.conf>qzs.log //去注释
worker_processes 1; //工作核心
events {
worker_connections 1024; //连接量
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
#增加站点
server {
listen 80;
server_name www.test.org test.org ;
location / {
root html/www;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name bbs.test.org;
location / {
root html/bbs;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 80;
server_name blog.test.org;
location / {
root html/blog;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
[root@E-host conf]# for n in www blog bbs;do echo "$n.test.org">../html/$n/index.html;done
[root@E-host conf]# for n in www blog bbs;do cat ../html/$n/index.html;done#301重定向
server {
listen 80;
server_name test.org;
rewrite ^/(.*) http://www.test.org/$1 permanent;
location / {
root html/blog;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}#状态模块
server {
listen 80;
server_name status.test.org;
location / {
stub_status on;
access_log off;
}
}
Active connections: 3 //并发连接数
server accepts handled requests
31 31 482
Reading: 0 Writing: 1 Waiting: 2
server 启动到现在处理胡连接
accepts启动到现在共车改一创建的握手
handled requests 总共处理了多少次请求
Reading 读取到客户端 header信息数
Writing 返回给客户端 header信息数
Waiting已经处理正在等候下一次请求指令胡驻留链接(开启 keep-alive的情况下)#解决恶意域名解析
server {
listen 80;
location / {
deny all;
}
}#日志记录及切割
http标签下添加
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
server标签下添加
access_log logs/www_access.log;
相关软件:syslog,rsyslog,Awstats,flume logstash scribe kafka
#调用配置文件方法
include extra/bbs.conf;
include extra/blog.conf;
停留在世界边缘,与之惜别