0920rhce作业

题目:

搭建一个基于https://www.zuoye.com:4443访问的web网站,网站首页在/www/https/,内容为zuoye

一.在虚拟机中安装https服务

[root@localhost ~]# mount /dev/sr0 /mnt
mount: /mnt: WARNING: device write-protected, mounted read-only.
[root@localhost ~]# yum install mod_ssl -y

二.创建对应目录,定义网页内容

[root@localhost ~]# mkdir /www/https -v
mkdir: created directory '/www/https'
[root@localhost ~]# echo zuoye > /www/https/index.html
[root@localhost ~]# cat /www/https/index.html
zuoye

三.定义配置文件/etc/httpd/conf.d/https.conf

[root@localhost ~]# vim /etc/httpd/conf.d/https.conf
listen 4443
<VirtualHost 192.168.136.140:4443>
    DocumentRoot /www/https
    ServerName www.zuoye.com
    SSLEngine on
    SSLCertificateFile /etc/pki/tls/certs/https.crt
    SSLCertificateKeyFile /etc/pki/tls/certs/https.key
</VirtualHost>
<Directory /www/https>
    AllowOverride None
    Require all granted
</Directory>

四.生成密钥和证书

[root@localhost conf.d]# cd /etc/pki/tls/certs/
[root@localhost certs]# openssl genrsa -aes128 2048 > https.key
[root@localhost certs]# ls
ca-bundle.crt  ca-bundle.trust.crt  https.key
[root@localhost certs]# openssl req -utf8 -new -key https.key -x509 -days 365 -out https.crt -set_serial 0
Enter pass phrase for https.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:sc
Locality Name (eg, city) [Default City]:cd
Organization Name (eg, company) [Default Company Ltd]:open
Organizational Unit Name (eg, section) []:ce
Common Name (eg, your name or your server's hostname) []:www.zuoye.com
Email Address []:admin@admin
[root@localhost certs]# ls
ca-bundle.crt  ca-bundle.trust.crt  https.crt  https.key

五.在虚拟机和Windows主机上添加域名

[root@localhost ~]# vim /etc/hosts
192.168.136.140 www.zuoye.com
C:\Windows\System32\drivers\etc\hosts
192.168.136.140 www.zuoye.com 

六.关闭selinux和防火墙,重启httpd服务

[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl restart httpd
Enter TLS private key passphrase for www.zuoye.com:443 (RSA) : ****

七.测试

[root@localhost ~]# curl https://192.168.136.140:4443 -k
zuoye
[root@localhost ~]# curl https://www.zuoye.com:4443 -k
zuoye
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值