当前位置:Gxlcms >
数据库问题 >
零基础学习云计算及大数据DBA集群架构师【企业级运维技术及实践项目2015年1月27日周三】
零基础学习云计算及大数据DBA集群架构师【企业级运维技术及实践项目2015年1月27日周三】
时间:2021-07-01 10:21:17
帮助过:2人阅读
1)/etc/nginx/conf.d
/*
[root@serverb conf.d]# vim ip.conf
server {
listen 192.168.1.88:80;
root 88.com;
index index.html;
}
server {
listen 192.168.1.87:80;
root 87.com;
index index.html;
}
[root@serverb ~]# ifconfig eth1:0 192.168.1.88
[root@serverb ~]# ifconfig eth1:1 192.168.1.87
[root@serverb ~]# mkdir /usr/local/nginx/88.com
[root@serverb ~]# echo ‘this is 88.com‘ > /usr/local/nginx/88.com/index.html
[root@serverb ~]# mkdir /usr/local/nginx/87.com
[root@serverb ~]# echo ‘this is 87.com‘ > /usr/local/nginx/87.com/index.html
}
Nginx 基于端口的虚拟主机配置
{
server {
listen 80;
root 80.com;
}
server {
listen 8080;
root 8080.com;
}
[root@serverb ~]# mkdir /usr/local/nginx/80.com
[root@serverb ~]# mkdir /usr/local/nginx/8080.com
[root@serverb ~]# echo ‘this is 80.com‘ > /usr/local/nginx/80.com/index.html
[root@serverb ~]# echo ‘this is 8080.com‘ > /usr/local/nginx/8080.com/index.html
}
基于名称的虚拟主机配置详解
{
1.
www.dabao.com
www.booboo.com
[root@serverb conf.d]# pwd
/etc/nginx/conf.d
[root@serverb conf.d]# cp default.conf www.booboo.com.conf
[root@serverb conf.d]# cp default.conf www.dabao.com.conf
[root@serverb conf.d]# vim www.booboo.com.conf
server {
listen 80;
server_name www.booboo.com;
location / {
root /usr/share/nginx/booboo.com;
index index.html index.htm;
}
}
[root@serverb conf.d]# vim www.dabao.com.conf
server {
listen 80;
server_name www.dabao.com;
root /usr/share/nginx/dabao.com;
index index.html index.htm;
}
[root@serverb conf.d]# mkdir /usr/share/nginx/dabao.com
[root@serverb conf.d]# mkdir /usr/share/nginx/booboo.com
[root@serverb conf.d]# echo hi,booboo > /usr/share/nginx/booboo.com/index.html
[root@serverb conf.d]# echo hi,dabao> /usr/share/nginx/dabao.com/index.html
#重启 nginx 服务
[root@serverb conf.d]# systemctl restart nginx.service
workstation 客户端测试
[root@workstation ~]# echo 172.25.15.10 www.dabao.com >> /etc/hosts
[root@workstation ~]# echo 172.25.15.10 www.booboo.com >> /etc/hosts
2.server_name
mail.dabao.com
news.dabao.com
www.news.dabao.com
www.sports.dabao.com
[root@serverb conf.d]# vim www.booboo.com.conf
server {
listen 80;
server_name ~www\..*\.booboo\.com;
location / {
root /usr/share/nginx/booboo.com;
index index.html index.htm;
}
}
[root@serverb conf.d]# vim www.dabao.com.conf
server {
listen 80;
server_name *.dabao.com;
root /usr/share/nginx/dabao.com;
index index.html index.htm;
}
3.location
www.booboo.com/news.html
[root@serverb conf.d]# cat www.booboo.com.conf
server {
listen 80;
server_name ~www.*\.booboo\.com;
location / {
root /usr/share/nginx/booboo.com;
index index.html index.htm;
}
location ~/news.html{
root /usr/share/nginx/dabao.com;
index index.html index.htm;
}
}
4.80 default
[root@serverb conf.d]# cp default.conf err.com.conf
[root@serverb conf.d]# vim err.com.conf
server {
listen 80 default;
#在监听端口号后边添加 default 字段,即代表该虚拟主机为默认虚拟主机
location / {
root /usr/share/nginx/err.com;
index index.html index.htm;
}
#创建该虚拟主机网页文件存放目录和首页文件,一般首页文件中即为报错信息
[root@serverb conf.d]# mkdir /usr/share/nginx/err.com
[root@serverb conf.d]# echo cannot found this virtual host name > /usr/share/nginx/err.com/index.html
#重启 nginx 服务
[root@serverb conf.d]# systemctl restart nginx.service
(4)workstation 客户端测试
}
零基础学习云计算及大数据DBA集群架构师【企业级运维技术及实践项目2015年1月27日周三】
标签: