目录
虚拟主机:
虚拟主机有三类:
相同IP不同端口
不同IP相同端口
相同IP相同端口不同域名
相同IP不同端口
//全局查找一下vhost的模板文件
[root@zzh ~]# find / -name "*vhosts.conf"
/usr/share/doc/httpd/httpd-vhosts.conf
//把模板文件拷贝到可放置虚拟主机配置文件的目录
[root@zzh ~]# cd /etc/httpd/conf.d/
[root@zzh conf.d]# cp /usr/share/doc/httpd/httpd-vhosts.conf ./
[root@zzh conf.d]# ls
README autoindex.conf httpd-vhosts.conf userdir.conf welcome.conf
//编辑复制的模板文件
[root@zzh conf.d]# vim httpd-vhosts.conf
<VirtualHost *:80> //定义自己所需的端口
DocumentRoot "/var/www/html/fjdz" //存放网页内容的根目录
ServerName www.fjdz.com //指定域名
ErrorLog "/var/log/httpd/www.fjdz.com-error_log" //错误日志位置
CustomLog "/var/log/httpd/www.fjdz.com-access_log" common //访问日志位置
</VirtualHost>
Listen 82
<VirtualHost *:82>
DocumentRoot "/var/www/html/ddz"
ServerName www.ddz.com
ErrorLog "/var/log/httpd/www.ddz.com-error_log"
CustomLog "/var/log/httpd/www.ddz.com-access_log" common
</VirtualHost>
//进入html目录下,下载飞机大战所需源码包
[root@zzh conf.d]# cd /var/www/html/
[root@zzh html]# mkdir fjdz //创建飞机大战目录
[root@zzh html]# ls //上传源码包
feijiedazhan.zip fjdz
[root@zzh html]# dnf -y install zip* //安装解压工具
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:22:56 ago on Sun Jul 24 03:26:55 2022.
Dependencies resolved.
===================================================================================
Package Architecture Version Repository Size
===================================================================================
Installing:
zip x86_64 3.0-23.el8 baseos 270 k
//解压源码包
[root@zzh html]# unzip feijiedazhan.zip
Archive: feijiedazhan.zip
//将解压文件移动到飞机大战目录下
[root@zzh html]# mv HTML5#U5168#U6c11#U98de#U673a#U5927#U6218#U5c0f#U6e38#U620f fjdz/
[root@zzh html]# cd fjdz/
[root@zzh fjdz]# ls
css img index.html js
//同样的操作,下载斗地主源码包
[root@zzh html]# mkdir ddz
[root@zzh html]# ls
ddz feijiedazhan.zip fjdz
[root@zzh html]# ls
ddz feijiedazhan.zip fjdz ''$'\346\226\227\345\234\260\344\270\273''.zip'
[root@zzh html]# unzip ''$'\346\226\227\345\234\260\344\270\273''.zip'
Archive: 斗地主.zip
[root@zzh html]# ls
'HTML5 canvas#U79fb#U52a8#U7aef#U6597#U5730#U4e3b#U5c0f#U6e38#U620f' ddz feijiedazhan.zip fjdz ''$'\346\226\227\345\234\260\344\270\273''.zip'
[root@zzh html]# mv 'HTML5 canvas#U79fb#U52a8#U7aef#U6597#U5730#U4e3b#U5c0f#U6e38#U620f' ddz/
[root@zzh html]# cd ddz/
[root@zzh ddz]# ls
DJDDZ.js JControls.js Prototype.js ResourceData.js img index.html
//检查配置文件是否存在语法错误
[root@zzh html]# httpd -t
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e2c4:3bc8:ed3a:ecac. Set the 'ServerName' directive globally to suppress this message
Syntax OK
[root@zzh html]# systemctl restart httpd //重启服务
//查看效果