web服务器

搭建web服务器,能够访问到网页内容为“小胖,你咋这么胖呢!”

一:安装httpd并启动

挂载:[root@localhost hh]# mount /dev/sr0 /mnt

安装:[root@localhost hh]# dnf install httpd -y

启动http服务:[root@localhost hh]# systemctl start httpd

二:关闭防火墙和selinux

[root@localhost html]# systemctl stop firewalld

[root@localhost html]# setenforce 0

三:更改配置,实现自定义配置

[root@localhost ~]# vim /etc/httpd/conf.d/vhosts.conf
 
<VirtualHost 192.168.101.129:80>
        ServerName 192.168.101.129
        DocumentRoot /www/openlab
</VirtualHost>
<Directory /www>
        AllowOverride none
        Require all granted
</Directory>


 四:根据配置创建资源文件

[root@localhost ~]# mkdir -p /www/openlab
[root@localhost ~]# echo "小胖,你怎么那么胖!" > /www/openlab/index.html

五:重启服务测试

[root@localhost ~]# systemctl restart httpd



六:查看


[root@localhost ~]# cat /www/xiaopang/index.html
小胖,你咋这么胖呢!
 

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

一:添加多个IP地址到服务端下

[root@localhost ~]# nmcli connection modify ens160 ipv4.method manual ipv4.addresses 192.168.101.129/24 +ipv4.addresses 192.168.101.139/24 +ipv4.addresses 192.168.101.149/24 ipv4.gateway 192.168.101.2 ipv4.dns 114.114.114.114 connection.autoconnect yes
添加成功后重启服务端
 


二:关闭防火墙和selinux

[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# setenforce 0


三:更改配置文件实现自定义设置

vim /etc/httpd/conf.d/vhosts.conf
<VirtualHost 192.168.101.139:80>
        ServerName www.xiaopang.com
        DocumentRoot /www/xiaopang
</VirtualHost>
 
<VirtualHost 192.168.101.149:80>
        ServerName www.dapang.com
        DocumentRoot /www/dapang
</VirtualHost>

四:根据配置创建资源文件

[root@localhost ~]# mkdir -p /www/xiaopang
[root@localhost ~]# mkdir -p /www/dapang
[root@localhost ~]# echo 难难难> /www/xiaopang/index.html
[root@localhost ~]# echo 啊啊啊 > /www/dapang/index.html

五:修改hosts文件,并且重启httpd

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值