nginx的安装配置详解
cat nginx.conf ##################################################usernobody;
worker_processes1;(一般和服务器的核数一样)
#error_loglogs/error.log;
#error_loglogs/error.lognotice;
#error_loglogs/error.loginfo;
#pid logs/nginx.pid;
这几行属于main区,Nginx核心功能模块
events {
worker_connections1024; 一个worker所能处理的多少的并发连接数
14 }
这几行属于event区,Nginx核心功能模块
http {
include mime.types;
default_typeapplication/octet-stream;
这个属于http区开始,Nginx核心功能模块
##################################################
实例搭建两个虚拟主机www.maiyat.combbs.maiyat.com
##################################################
cp nginx.conf nginx.conf.bak
egrep -v "#|^$" nginx.conf.default > nginx.conf
worker_processes1; worker进程的数量
events { 事件区块的开始
worker_connections1024; 每个woker进程支持的最大连接数
}事件区块结束
http { http区块开始
include mime.types;Nginx支持的媒体类型库文件包含
default_typeapplication/octet-stream;默认的媒体类型
sendfile on; 开启高效传输模式
keepalive_timeout65; 连接超时
server { 第一个server区块开始,代表一个独立的虚拟主机站点
listen 80; 提供服务的端口,默认是80
server_namewww.maiyat.com;提供服务的域名主机名
location / { 第一个Location区块的开始
root html/www; 站点的根目录,相对路径,相对于Nginx的安装路径
indexindex.html index.htm; 默认的首页文件,多个用空格分开
} 第一个区块结束
}
server {
listen 80;
server_namebbs.maiyat.com;
location / {
root html/bbs;
indexindex.html index.htm;
}
error_page 500 502 503 504/50x.html; 出现对应的http状态码使用50x.html回应
location = /50x.html { Location区块的开始,访问50x.html
root html; 指定对应的站点目录为html
}
}
} http区块结束
页:
[1]