Linux搭建Web网站

 1.基于域名[www.openlab.com](http://www.openlab.com)可以访问网站内容为 welcome to openlab!!!

一 .

#创建文件夹
[root@localhost conf.d]# mkdir -pv /www/ip/{100,200}
#将要显示的html页面内容写入该文件夹中,文件名为index.html
[root@localhost conf.d]# echo "Welcome to openlab !!" > /www/ip/100/index.html
#编写配置文件
[root@localhost conf.d]# cat /etc/httpd/conf.d/httpd-vhosts.conf 
<VirtualHost 192.168.181.100:80>
    DocumentRoot "/www/ip/100"
    ServerName www.openlab.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "/var/log/httpd/100-error_log"
</VritualHost>
<Directory "/www/ip">
	AllowOverride None
	Require all granted
</Directory>
#检查防火墙状态和selinux
[root@localhost 100]# getenforce 
Permissive
[root@localhost 100]# systemctl status firewalld
○ firewalld.service - firewalld - dynamic firewall daemon
     Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
     Active: inactive (dead)
       Docs: man:firewalld(1)



在windows中找到hosts,并在文件中编写ip和域名

最后浏览器访问www.openlab.com

二.  

2.给该公司创建三个子界面分别显示学生信息,教学资料和缴费网站,基于[www.openlab.com/student](http://www.openlab.com/student) 网站访问学生信息,[www.openlab.com/data](http://www.openlab.com/data)网站访问教学资料[www.openlab.com/money网站访问缴费网站](http://www.openlab.com/money网站访问缴费网站)。

#切换到存放html的文件夹
[root@localhost conf.d]# cd /www/ip/100
#创建学生目录
[root@localhost 100]# mkdir student
[root@localhost 100]# echo "this is student" > student/index.html

访问学生信息

#创建教学资料
[root@localhost 100]# mkdir jiaoxueziliao
[root@localhost 100]# echo "this is book" > jiaoxueziliao/index.html

 访问教学资料

#创建缴费
[root@localhost 100]# mkdir money
[root@localhost 100]# echo "this is money" > money/index.html

访问缴费

三. 

 3.要求 
​  (1)学生信息网站只有song和tian两人可以访问,其他用户不能访问。
​  (2)访问缴费网站实现数据加密基于https访问。

第一小题:

#修改student控制文件
[root@localhost 100]# cat /etc/httpd/conf.d/httpd-vhosts.conf
<VirtualHost 192.168.181.100:80>
    DocumentRoot "/www/ip/100"
    ServerName www.openlab.com
    ServerAlias www.dummy-host.example.com
    ErrorLog "/var/log/httpd/100-error_log"
</VirtualHost>
<Directory "/www/ip">
	AllowOverride None
	Require all granted
</Directory>
<directory /www/ip/100/student> 
	authtype basic
	authname "please login:"
	authuserfile /etc/httpd/mymima 
	require user song tian  #test
</directory>
#增添指定登录用户
[root@localhost conf.d]# htpasswd -c /etc/httpd/mymima song
New password: 
Re-type new password: 
Adding password for user song
[root@localhost conf.d]# htpasswd  /etc/httpd/mymima tian
New password: 
Re-type new password: 
Adding password for user tian

访问结果:

第二小题:

#创建CA证书和秘钥
[root@localhost certs]# openssl genrsa -aes128 2048 > jiami.key
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
[root@localhost certs]# openssl req -utf8 -new -key jiami.key -x509 -days 100 -out jiami.crt
Enter pass phrase for jiami.key:
#https的配置文件
<virtualhost 192.168.181.100:443>
        servername www.openlab.com
        documentroot /www/ip/100
        sslengine on
		SSLCertificateFile /etc/pki/tls/certs/jiami.crt
		SSLCertificateKeyFile /etc/pki/tls/certs/jiami.key
</virtualhost>
<directory /www/ip/100>
  allowoverride none
  require all granted
</directory>

访问结果

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

North433

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值