web服务器练习(二)

题目

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

步骤

# 搭建www.zuoye.com

# 建立https目录, index.html文件
[root@localhost www]# mkdir /www/https
[root@localhost www]# echo exercise > /www/https/index.html
# 配置https.conf文件
[root@localhost www]# cd /etc/httpd/conf.d
[root@localhost conf.d]# vim https.conf
<VirtualHost 192.168.182.132:80>
    DocumentRoot "/www/https"
    ServerName www.zuoye.com
    ErrorLog "/www/https/error_log"
    CustomLog "/www/https/access_log" common
	sslengine on
	sslcertificatefile /www/https/https.crt
	sslcertificatekeyfile /www/https/https.key
</VirtualHost>
<directory /www>
	allowoverride none
	require all granted
</directory>

# 配置/etc/hosts文件
[root@localhost conf.d]# vim /etc/hosts
	192.168.182.132  www.zuoye.com
# 关闭防火墙,selinux  重启httpd服务
[root@localhost conf.d]# systemctl stop firewalld
[root@localhost conf.d]# setenforce 0
[root@localhost conf.d]# systemctl restart httpd


# 建立密钥
[root@localhost https]# openssl genrsa -aes128 2048 > https.key
Generating RSA private key, 2048 bit long modulus (2 primes)
....................................................+++++
....................................................................+++++
e is 65537 (0x010001)
Enter pass phrase:
139715488741184:error:28078065:UI routines:UI_set_result_ex:result too small:crypto/ui/ui_lib.c:905:You must type in 4 to 1023 characters
Enter pass phrase:
Verifying - Enter pass phrase:
[root@localhost https]# openssl req -utf8 -new -key https.key -x509 -days 100 -out http
s.crt
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]:gd
State or Province Name (full name) []:gc
Locality Name (eg, city) [Default City]:ci
Organization Name (eg, company) [Default Company Ltd]:ch
Organizational Unit Name (eg, section) []:c^Hac
Common Name (eg, your name or your server's hostname) []:ac
Email Address []:

# 配置https.conf文件, 改端口为443和添加sslcertificatefile,sslcertificatekeyfile
[root@localhost https]# vim /etc/httpd/conf.d/https.conf
<VirtualHost 192.168.182.132:443>
    DocumentRoot "/www/https"
    ServerName www.zuoye.com
    ErrorLog "/www/https/error_log"
    CustomLog "/www/https/access_log" common
	sslengine on
	sslcertificatefile /www/https/https.crt
	sslcertificatekeyfile /www/https/https.key
</VirtualHost>
<directory /www>
	allowoverride none
	require all granted
</directory>
# 再重启服务
[root@localhost https]# systemctl restart httpd
Enter TLS private key passphrase for www.zuoye.com:443 (RSA) : ****

# 测试
[root@localhost https]# curl -k https://www.zuoye.com
exercise

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值