1案例1:独立web站点的快速部署
1.1问题
本例要求为http://server0.example.com配置web站点,要求如下:
- 从http://classroom/pub/materials/station.html下载一个主页文件,将其重命名为index.html
- 将此文件拷贝到站点DocumentRoot目录下,不要对文件index.html的内容作任何修改
- 使用elinks或Firefox浏览上述web站点
1.2方案
Web网站服务器端:软件包httpd、系统服务httpd
web网站浏览器:软件包elink或Firefox
传输协议及端口:TCP 80
Web网站服务器端配置文件:
- /etc/httpd/conf/httpd.conf
- /etc/httpd/conf.d/*.conf
默认首页文件:index.html
httpd网站文档的默认根目录:/var/www/html
URL(Uniform Resource Locator,统一资源定位器)网址的基本组成:
http://服务器地址[:端口号]/目录/文件名
对于需要验证的FTP资源,还需要制定用户名密码信息:
ftp://用户名:密码@服务器地址[:端口号]/目录/文件名
1.3步骤
实现此案例需要按照如下步骤进行。
步骤一:构建及部署网站服务器
1) 安装软件包httpd
[root@server0 ~]# yum -y install httpd
.. ..
2) 部署网页
[root@server0 ~]# cd /var/www/html/
[root@server0 html]# wget http://classroom/pub/materials/station.html -O index.html //下载网页
.. ..
2016-11-26 19:33:49 (1.36 MB/s) - ‘index.html’ saved [14/14]
[root@server0 html]# cat index.html //检查网页文件
Default Site.
3)启动系统服务httpd,并设置开机自启
[root@server0 html]# systemctl restart httpd
[root@server0 html]# systemctl enable httpd
ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
步骤二:访问网站服务器
1)使用elinks浏览器查看
Elinks浏览器可以在命令行模式显示出网页文件,经常用来测试网站的可用性。
[root@desktop0 ~]# yum -y install elinks //安装elinks
.. ..
[root@desktop0 ~]# elinks -dump http://server0.example.com/ //访问指定网址
Default Site.
2)使用firefox浏览器查看
Firefox浏览器支持更多网页性特性,是访问复杂网页、网址的优秀工具。
在桌面终直接运行“Firefox http://server0.example.com/”,或者通过菜单快捷方式打开Firefox浏览器在输入对应网址,都可以看到目标网页