Apache搭建网站

1.关闭防火墙

[root@server ~]# setenforce 0
[root@server ~]# systemctl stop firewalld

2.安装httpd服务

[root@server ~]# yum  install  httpd  mod_ssl  -y

3.新建网页目录

[root@server /]# mkdir -p /www/opanlab

4.修改/etc/hosts的映射(使其可以域名访问)

[root@server /]# vim /etc/hosts
192.168.136.133 www.openlab.com                             

5.给网站主页写入内容

[root@server ~]# echon "openlab欢迎你的加入" > /www/openlab/index.html

6.编辑配置文件

 <VirtualHost 192.168.136.133>
        DocumentRoot    /www/openlab
        ServerName      "www.opanlab.com"
       <Directory /www/openlab>
              AllowOverride None
              require all granted
        </Directory>
 </virtualHost>

image.png
7.重启服务

[root@server ~]# systemctl restart httpd

image.png
二、创建教学资料网站

[root@server /]# mkdir -p /www/openlab/data
[root@server /]# echo '资料下载' > /www/openlab/data/index.html
[root@server /]# vim /etc/httpd/conf/httpd.conf
[root@server /]# systemctl restart httpd
<Virtualhost 192.168.136.133>
        DocumentRoot    /www/openlab/data
        alias   /data   /www/openlab/data
        Servername      "www.openlab.com"
</virtualhost>
        <Directory /www/openlab/data>
                allowoverride none
                require all granted
        </Directory>
重启服务

image.png
三、创建学生网站

[root@server ~]# mkdir -p /www/openlab/student
[root@server ~]# vim /etc/httpd/conf/httpd.conf 
[root@server ~]# echo 'student' > /www/openlab/student/index.html
[root@server ~]# useradd song
[root@server ~]# passwd song
[root@server ~]# useradd tian
[root@server ~]# passwd tian
[root@server ~]# htpasswd -c /etc/httpd/passwd song
[root@server ~]# htpasswd /etc/httpd/passwd tian
[root@server ~]# vim /etc/httpd/conf/httpd.conf 
<Directory /www/openlab/student>
        authuserfile /etc/httpd/passwd
        authname "student"
        authtype basic
        require user tian song
</directory>

image.png
image.png

四、创建缴费网站

[root@server ~]# vim /etc/httpd/conf/httpd.conf 
[root@server ~]# mkdir /www/openlab/money
[root@server ~]# echo 'money' > /www/openlab/money/index.html
[root@server ~]# vim /etc/httpd/conf/httpd.conf 
[root@server ~]# systemctl restart httpd

image.png
image.png

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值