linux nginx 虚拟主机,nginx虚拟主机include用法

基于域名虚拟主机

wroker_processes 1;#进程数

evevts { #事件区块

worker_connections 1024;#每个work进程支持最大并发

}

http { #http区域开始

include mime.types; #nginx支持媒体类型库文件

default_type application/octet-stream;#默认的媒体类型

sendfile on;#开启高效传输模式

keepalive_timeout 65;#连接超时

server { #第一个server区域,单独的虚拟主机站点

liseten 80;#提供的服务端口

server_nanme www.linuxea.com;#提供服务的域名主机名

location / { # 第一个location区域开始

root /www/www; #站点目录

index index.html index.htm; #默认首页文件

}

}

server {

liseten 80;

server_nanme bbs.linuxea.com;

location / {

root /www/bbs;

index index.html index.htm;

}

}

}

2,站点目录创建

mkdir /www/{www,bbs} -p

基于端口则修改端口即可!

基于ip:liseten IPADDR:80;

3,配置管理

inginx的include使用

user nginx;

worker_processes 1;

error_log /var/log/nginx/error.log;

pid /var/run/nginx.pid;

events {

worker_connections 1024;

}

http {

include /etc/nginx/mime.types;

default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent "$http_referer" '

'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;

keepalive_timeout 65;

#nginx_vhost config

include /etc/nginx/conf.d/www.conf;

include /etc/nginx/conf.d/bbs.conf;

include /etc/nginx/conf.d/blog.conf;

}

[root@Rsync conf.d]# cat /etc/nginx/conf.d/www.conf

server {

listen 80;

server_name www.linuxea.com;

location / {

root /www/www;

index index.html index.htm;

}

}

查看

[root@Rsync conf.d]# cat /etc/nginx/conf.d/bbs.conf

server {

listen 80;

server_name bbs.linuxea.com;

location / {

root /www/bbs;

index index.html index.htm;

}

}

[root@Rsync conf.d]# cat /etc/nginx/conf.d/blog.conf

server {

listen 80;

server_name blog.linuxea.com;

location / {

root /www/blog;

index index.html index.htm;

}

}

[root@Rsync conf.d]# mkdir /www/{www,bbs,blog} -p

[root@Rsync conf.d]# echo www.linuxea.com >/www/www/index.html

[root@Rsync conf.d]# echo bbs.linuxea.com >/www/bbs/index.html

[root@Rsync conf.d]# echo blog.linuxea.com >/www/blog/index.html

[root@Rsync conf.d]# curl www.linuxea.com

www.linuxea.com

[root@Rsync conf.d]# curl bbs.linuxea.com

bbs.linuxea.com

[root@Rsync conf.d]# curl blog.linuxea.com

blog.linuxea.com

[root@Rsync conf.d]#

别名:

1,server_name blog.linuxea.com www.blog.linuxea.com;

2,域名解析

[root@Rsync conf.d]# cat /etc/nginx/conf.d/blog.conf

server {

listen 80;

server_name blog.linuxea.com;

location / {

root /www/blog;

index index.html index.htm;

}

}

状态页面:

[root@Rsync conf.d]# cat status.conf

server{

listen 80;

server_name status.linuxea.com;

location / {

stub_status on;

access_log off;

}

}

status.linuxea.com

Active connections: 2 --->活动连接数

server accepts handled requests

2 2 1

server启动到查看处理的连接

accepts成功建立的握手数

handled处理的请求数

Reading: 1 Writing: 1 Waiting: 0

reading:读取到客户端的header信息数

writing:返回给客户端的header信息数

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

5c1967c5325842cec010c6abd3e07965.gif

除非另有说明,否则本站上的内容根据以下许可进行许可: CC署名-非商业性使用-相同方式共享4.0国际许可协议4.0进行许可

本文作者:www.linuxea.com for Mark

文章链接:http://www.linuxea.com/995.html (转载请注明本文出处和本章链接)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值