大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
今天小编就为大家带来一篇apache的虚拟web主机配置图文介绍的文章。小编觉得挺不错的,为此分享给大家做个参考。一起跟随小编过来看看吧。
在下花园等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站设计、网站制作 网站设计制作定制网站建设,公司网站建设,企业网站建设,成都品牌网站建设,网络营销推广,外贸网站建设,下花园网站建设费用合理。@[toc]
apache 常用的功能,虚拟主机
IP不同,端口相同
IP相同,端口不通
[root@localhost ~]# yum install bind httpd -y
Package 32:bind-9.11.4-9.P2.el7.x86_64 already installed and latest version
Package httpd-2.4.6-90.el7.centos.x86_64 already installed and latest version
Nothing to do
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]#
[root@localhost ~]# vim /etc/named.conf
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
recursing-file "/var/named/data/named.recursing";
secroots-file "/var/named/data/named.secroots";
allow-query { any; };
[root@localhost ~]# vim /etc/named.rfc1912.zones
zone "kgc.com" IN {
type master;
file "kgc.com.zone";
allow-update { none; };
};
zone "accp.com" IN {
type master;
file "accp.com.zone";
allow-update { none; };
};
[root@localhost ~]# cd /var/named/
[root@localhost named]# ls
data dynamic named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p named.localhost kgc.com.zone
[root@localhost named]# vim kgc.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.247.150
~
[root@localhost named]# cp -p kgc.com.zone accp.com.zone
[root@localhost named]# systemctl start named
[root@localhost httpd]# ls
conf conf.d conf.modules.d logs modules run
[root@localhost httpd]# ls -l
total 0
drwxr-xr-x. 2 root root 37 Dec 12 14:45 conf
drwxr-xr-x. 2 root root 82 Dec 12 14:45 conf.d
drwxr-xr-x. 2 root root 146 Dec 12 14:45 conf.modules.d
lrwxrwxrwx. 1 root root 19 Dec 12 14:45 logs -> ../../var/log/httpd
lrwxrwxrwx. 1 root root 29 Dec 12 14:45 modules -> ../../usr/lib64/httpd/modules
lrwxrwxrwx. 1 root root 10 Dec 12 14:45 run -> /run/httpd
[root@localhost httpd]#
[root@localhost httpd]# cd conf
[root@localhost conf]# ls
httpd.conf magic
[root@localhost conf]# mkdir extra
[root@localhost conf]# cd extra/
[root@localhost extra]# ls
[root@localhost extra]#
/etc/httpd/conf/extra/vhost.conf文件中
[root@localhost extra]# vim vhost.conf
1
2 DocumentRoot "/var/www/html/kgc"
3 ServerName www.kgc.com
4 Errorlog "logs/www.kgc.com.error_log"
5 Customlog "logs/www.kgc.comaccess_log" common
6
7 Require all granted
8
9
10
11
12 DocumentRoot "/var/www/html/accp"
13 ServerName www.accp.com
14 Errorlog "logs/www.accp.com.error_log"
15 Customlog "logs/www.accp.comaccess_log" common
16
17 Require all granted
18
19
### 2.1.5 创建两个web站点的首页,首页文件index.html在/var/www/html下面的站点目录中
```bash
[root@localhost extra]# cd /var/
[root@localhost var]# ls
account cache db games kerberos local log named opt run target www
adm crash empty gopher lib lock mail nis preserve spool tmp yp
[root@localhost var]# cd www
[root@localhost www]# ls
cgi-bin html
[root@localhost www]# cd html
[root@localhost html]# ls
[root@localhost html]# mkdir kgc accp
[root@localhost html]# ls
accp kgc
[root@localhost html]# echo "this is accp web" > accp/index.html
[root@localhost html]# echo "this is kgc web" > kgc/index.html
[root@localhost html]# tree accp kgc
accp
└── index.html
kgc
└── index.html
0 directories, 2 files
[root@localhost html]#
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
354 Include conf/extra/vhost.conf
[root@localhost html]# systemctl start httpd
[root@localhost html]# netstat -natp | grep httpd
tcp6 0 0 :::80 :::* LISTEN 79262/httpd
[root@localhost html]# vim /etc/httpd/conf/extra/vhost.conf
//复制修改增加
11
12 DocumentRoot "/var/www/html/kgc02"
13 ServerName www.kgc02.com
14 Errorlog "logs/www.kgc02.com.error_log"
15 Customlog "logs/www.kgc02.comaccess_log" common
16
17 Require all granted
18
19
[root@localhost html]# ls
accp kgc
[root@localhost html]# cp -p kgc kgc02
cp: omitting directory ‘kgc’
[root@localhost html]# mkdir kgc02
[root@localhost html]# echo "this is web kgc02" >kgc02/index.html
[root@localhost html]#
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
41 Listen 192.168.247.150:80
42 Listen 192.168.247.150:8080
43 #Listen 80
[root@localhost html]# systemctl restart httpd
[root@localhost html]# netstat -napt | grep httpd
tcp 0 0 192.168.247.150:8080 0.0.0.0:* LISTEN 91814/httpd
tcp 0 0 192.168.247.150:80 0.0.0.0:* LISTEN 91814/httpd
[root@localhost html]# ifconfig
ens33: flags=4163 mtu 1500
inet 192.168.247.150 netmask 255.255.255.0 broadcast 192.168.247.255
ens36: flags=4163 mtu 1500
inet 192.168.247.158 netmask 255.255.255.0 broadcast 192.168.247.255
[root@localhost html]# vim /etc/httpd/conf/extra/vhost.conf
DocumentRoot "/var/www/html/accpaccp"
ServerName www.accpaccp.com
Errorlog "logs/www.accpaccp.com.error_log"
Customlog "logs/www.accpaccp.comaccess_log" common
Require all granted
[root@localhost html]# ls
accp accp02 kgc kgc02
[root@localhost html]# mkdir accpaccp
[root@localhost html]# echo "this is 192.168.247.158" > accpaccp/index.html
[root@localhost html]# vim /etc/httpd/conf/httpd.conf
Listen 192.168.247.158:80
[root@localhost html]# systemctl restart httpd
[root@localhost html]# netstat -natp | grep httpd
tcp 0 0 192.168.247.150:8080 0.0.0.0:* LISTEN 123662/httpd
tcp 0 0 192.168.247.158:80 0.0.0.0:* LISTEN 123662/httpd
tcp 0 0 192.168.247.150:80 0.0.0.0:* LISTEN 123662/httpd
#####因为没有配置dns解析,所以需要输入IP地址去进入网站,接下来增加这个ip地址的域名解析
[root@localhost html]# vim /etc/named.rfc1912.zones
zone "accpaccp.com" IN {
type master;
file "accpaccp.com.zone";
allow-update { none; };
};
[root@localhost html]# cd /var/named
[root@localhost named]# ls
accp.com.zone data dynamic kgc.com.zone named.ca named.empty named.localhost named.loopback slaves
[root@localhost named]# cp -p accp.com.zone accpaccp.com.zone
[root@localhost named]# vim accpaccp.com.zone
$TTL 1D
@ IN SOA @ rname.invalid. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS @
A 127.0.0.1
www IN A 192.168.247.158
[root@localhost named]# systemctl restart named
[root@localhost named]# vim /var/www/html/accpaccp/index.html
hello world
hello world
[root@localhost named]# systemctl restart httpd
上述就是apache的虚拟web主机配置的详细内容,详细使用情况还需要大家自己动手实验使用过才能领会。如果想了解更多相关内容,欢迎关注创新互联行业资讯频道!
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。