nginx虚拟主机
2016-03-23 10:24
633 查看
一、编译安装完成nginx在这就不说了,前文有具体的安装过程;
二、排除不需要的内容;
[root@nginx ~]# egrep -v "#|^$" /etc/nginx/nginx.conf >/tmp/nginx.conf
三、修改内容,拷贝到cp /tmp/nginx.conf /etc/nginx/nginx.conf
######################################################################
[root@nginx data]# cat /etc/nginx/nginx.conf
user nginx nginx;
worker_processes 6;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etangbo.com;
access_log /app/log/www/host.access.log;
location / {
root /data/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.etangbo.com;
access_log /app/log/bbs/host.access.log;
location / {
root /data/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.etangbo.com;
access_log /app/log/blog/host.access.log;
location / {
root /data/blog;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
[root@nginx data]#
######################################################################
四、创建网页文件目录和授权
mkdir /data/www -p
chown -R nginx.nginx /data/www/
mkdir /app/log -p
[root@nginx ~]# /usr/sbin/nginx -s reload # 加载配置文件
五、本地hosts做解析:C:\Windows\System32\drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
192.168.11.32 www.etangbo.com
192.168.11.32 bbs.etangbo.com
192.168.11.32 blog.etangbo.com
二、排除不需要的内容;
[root@nginx ~]# egrep -v "#|^$" /etc/nginx/nginx.conf >/tmp/nginx.conf
三、修改内容,拷贝到cp /tmp/nginx.conf /etc/nginx/nginx.conf
######################################################################
[root@nginx data]# cat /etc/nginx/nginx.conf
user nginx nginx;
worker_processes 6;
events {
use epoll;
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name www.etangbo.com;
access_log /app/log/www/host.access.log;
location / {
root /data/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.etangbo.com;
access_log /app/log/bbs/host.access.log;
location / {
root /data/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.etangbo.com;
access_log /app/log/blog/host.access.log;
location / {
root /data/blog;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
[root@nginx data]#
######################################################################
四、创建网页文件目录和授权
mkdir /data/www -p
chown -R nginx.nginx /data/www/
mkdir /app/log -p
[root@nginx ~]# /usr/sbin/nginx -s reload # 加载配置文件
五、本地hosts做解析:C:\Windows\System32\drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
192.168.11.32 www.etangbo.com
192.168.11.32 bbs.etangbo.com
192.168.11.32 blog.etangbo.com
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- 网站502与504错误分析
- 用zabbix监控nginx_status状态
- 互联网业内的迷雾 谨慎选择虚拟主机
- 选定虚拟主机 性能凸显优势
- 开通虚拟主机时提示Server.CreateObject失败的解决办法
- 用vbs实现虚拟主机和域名查循的脚本
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 使用C#实现读取系统配置文件的代码实例讲解
- 把Lua编译进nginx步骤方法
- 星外虚拟主机平台国内五大域名接口设置方法