RHCE·贰
实验要求具体如下
搭建一个基于https://www.zuoye.com:4443访问的web网站,网站首页在/www/https/,内容为zuoye
提前工作
- 安装mod_ssl包
- 安装httpd包
添加IP并激活
[root@localhost ~]# nmcli connection modify ens160 ipv4.method manual +ipv4.addresses 192.168.30.140/24 ipv4.gateway 192.168.30.2 ipv4.dns 192.168.30.2 autoconnect yes
[root@localhost ~]# nmcli connection up ens160
定义服务配置文件
[root@localhost ~]# cd /etc/httpd/conf.d
[root@localhost conf.d]# vim https.conf
<VirtualHost 192.168.30.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]# openssl req -utf8 -new -key https.key -x509 -days 365 -out https.crt
输入各项数据
创建目录,并定义网页内容
[root@localhost /]# mkdir -p /www/https
[root@localhost /]# echo zuoye > /www/https/index.html
重启服务
[root@localhost ~]# curl https://192.168.30.140:4443 -k
zuoye
[root@localhost ~]# curl https://www.zuoye.com:4443 -k
zuoye
实验·完