静态Web网站的搭建流程及例题--http

一、搭建基于ip访问的网站内容为helloword的web网站

1、挂载----(获取软件包)
mount /dev/sr0 /mnt (获取软件包)
2(定义yum仓库文件)

.vim /etc/yum.repos.d/base.repo   普通文本文件
          (先enter几行再输入)
[base]        源标识名称           (表示仓库存在)
name=haha     源名称            (仓库命名)
baseurl=file:///mnt         (定义包的资源定位符/定义安装软件包的绝对路径)
gpgcheck=0

一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
3、进行http安装
[root@llh ~]# yum install httpd -y—
显示: Installed: httpd.x86_64 0:2.4.6-40.el7
[root@llh ~]# rpm -ql httpd -ql 查看软件包释放的文件列表[Query list
4、--------(重启)激活http服务
[root@llh ~]# systemctl (re)start httpd(.service) enter后无错误提示即激活成功
激活后查看状态 [root@llh ~]# systemctl status httpd
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)5、
5、

[root@b ~]# systemctl stop firewalld.service  --关闭防火墙
[root@llh ~]# setenforce 0--------关闭selinux
root@b ~]# vim /etc/httpd/conf/httpd.conf-------查看主配置文件
切换到conf.d下查看--子配置文件

一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
6、写入网站内容
[root@b conf.d]# cd /var/www/html------切换到web服务的根下进行页面内容更改
[root@b html]# vim index.html
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
7、可在火狐浏览器中进行测试
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)

【当有多个主机ip时,可以用以下对不同主机进行标识,去共享不同的内容,由此客户通过不同ip可访问到不同网站内容
[root@b html]# vim /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf------精确匹配
<VirtualHost 😡@Port@@>---------ip:服务端口号
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot “@@ServerRoot@@/docs/dummy-host.example.com”----可自定义根目录
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog “/var/log/httpd/dummy-host.example.com-error_log”
CustomLog “/var/log/httpd/dummy-host.example.com-access_log” common
</ VirtualHost >
若没有以上内容,则通过匹配document /var/www/html访问】
【注:当目录下多个文件时
[root@b html]# mkdir /www/kk
[root@b html]# mkdir /www/kk/ll
[root@b html]# echo this is hh > /www/kk/ll/index.html
[root@b html]# curl http://192.168.154.131/kk/ll
*/**最后一定要加/
this is hh】

例题二:搭建一个可通过端口8909能够访问到网页内容为“坚决不串门子不送命”的web服务

1、
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
2、创建内容所在目录、写入网站内容*
[root@llh ~]# mkdir /llh
[root@llh ~]# echo 坚决不串门子不送命!> /llh/index.htm
**3重启服务
[root@llh ~]# systemctl restart httpd.service
[root@llh ~]# systemctl status httpd -l
4、测试
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)

例题三:要求搭建一个web服务器,创建基于域名的虚拟主机,能够使用www.xiaopang。Com和www.dapang.com 访问各自网站内容自定义,网站存放路径分别为/xiaopang 和/dapang。

1、再添加一个ip地址
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
**2、[**root@llh html]# vim /etc/httpd/conf.d/haha.conf------在子配置文件中修改配置
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
3、创建内容所在目录
[root@llh html]# mkdir /{dapang,xiaopang}
4、写入网站内容
[root@llh html]# echo 大胖真胖 >/dapang/index.html
[root@llh html]# echo 小胖也胖 >/xiaopang/index.html
5、
关闭防火墙 systemctl stop firewalld.service –
关闭selinux setenforce 0--------关闭selinux
重启服务: systemctl restart httpd.service
6、修改linux的dns解析的数据库信息,使其网址域名与其对应的ip地址相关联。
[root@llh html]# vim /etc/hosts
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
也可修改windows的hosts文件,通过windows主机的浏览器进行浏览(ie)在C盘/windows/system32/drivers/etc/hosts 下进行修改,修改方式与linux相同
7、测试:
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)
一、基本步骤1、mount  /dev/sr0  /mnt   (获取软件包)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值