给openlab搭建web网站

 

1.写好仓库并挂载好后,开始准备相关的包和关闭防火墙等操作

yum install httpd -y  //下载httpd包

yum install mod_ssl  -y//下载mod-ssl 用于加密

systemctl stop firewalld //关闭防火墙

setenforce 0

2.然后写配置文件


[root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf
[root@localhost ~]# cat /etc/httpd/conf.d/vhost.conf
<VirtualHost 192.168.152.134:80>
        Servername www.openlab.com
        DocumentRoot /var/www/openlab
</VirtualHost>
<Directory /www>
        AllowOverride none
        Require all granted
</Directory>
[root@localhost ~]# mkdir /var/www/openlab 
[root@localhost ~]# echo 1111 > /var/www/openlab/index.html 
[root@localhost conf.d]# vim /etc/hosts 
[root@localhost conf.d]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.152.134 www.openlab.com
[root@localhost ~]# systemctl restart httpd 
[root@localhost ~]# curl www.openlab.com
welcome to openlab!!!


3.在刚刚的文件下创建三个子网页,并写入内容


[root@localhost ~]# mkdir /var/www/openlab/student
[root@localhost ~]# mkdir /var/www/openlab/data
[root@localhost ~]# mkdir /var/www/openlab/money
[root@localhost /]# echo xsxx >  / var/www/openlab/student/index.html
[root@localhost /]#  echo jxzy >  / var/www/openlab/data/index.html
[root@localhost /]#  echo xsjf  > / var/www/openlab/money/index.html

创建song和tian用户并设置密码

[root@localhost ~]# htpasswd -c /etc/httpd/yonghu song
New password: 
Re-type new password: 
Adding password for user song
[root@localhost ~]# htpasswd -c /etc/httpd/yonghu tian
New password: 
Re-type new password: 
Adding password for user tian
[root@localhost ~]# vim /etc/httpd/conf.d/vhost.conf 
[root@localhost ~]# cat /etc/httpd/conf.d/vhost.conf 
<VirtualHost 192.168.152.134:80>
        Servername www.openlab.com
        DocumentRoot /var/www/openlab
</VirtualHost>
<Directory /var/www/openlab>
        AllowOverride none
        Require all granted
</Directory>
<directory /var/www/openlab/student>
  allowoverride none
  authtype basic
  authname "please login"
  authuserfile /etc/httpd/yonghu
  require user song tian
</directory>

4.加密

[root@server ~]# cd /etc/pki/tls/private/
[root@server private]# openssl genrsa -aes128 2048 > jiami.key
[root@localhost private]# cd /etc/pki/tls/certs/
[root@localhost certs]# openssl req -utf8 -new -key /etc/pki/tls/private/jiami.key -x509 -days 365 -out jiami.crt

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值