大同本地做网站的,会泽网站建设,南京自助建站,新能源汽车价格表3万左右需要下载httpd模块#xff1a;yum install httpd -y
前提需要先搭建一个虚拟主机来测试证书创建的效果#xff0c;以下面www.hehe.com为例#xff0c;可以参考创建#xff1a;
[rootlocalhost conf.d]# vim vhost.conf
directory /www
allowoverride none
requi…需要下载httpd模块yum install httpd -y
前提需要先搭建一个虚拟主机来测试证书创建的效果以下面www.hehe.com为例可以参考创建
[rootlocalhost conf.d]# vim vhost.conf
directory /www
allowoverride none
require all granted
/directoryvirtualhost 192.168.54.131:443 #端口要改为443
documentroot /www/hehe
servername www.hehe.com
alias /hehe /usr/local/mysecret #目录别名
/virtualhost
虚拟主机创建完成后再去创建对应的目录和文件以及写入网页的内容
[rootlocalhost conf.d]# mkdir /www/hehe
[rootlocalhost conf.d]# echo hehe /www/hehe/index.html
在虚拟机本地解析和Windows本地解析文件中添加这条域名解析虚拟机在/etc/hosts Windows在C:\Windows\System32\drivers\etc 192.168.54.131 www.hehe.com 我们可以给www.hehe.com创建证书具体创建证书步骤如下
1.下载mod_ssl模块
[rootlocalhost conf.d]# yum install -y mod_ssl
2.生成密钥
[rootlocalhost certs]# openssl genrsa jiami.key
3.移动密钥到/etc/pki/tls/private/
[rootlocalhost certs]# mv jiami.key ../private/
4.返回到certs目录下创建证书
[rootlocalhost certs]# openssl req -utf8 -new -key ../private/jiami.key -x509 -days 100 -out jiami.crt
Country Name (2 letter code) [XX]:86 #证书的地区86 中国
State or Province Name (full name) []:rhce
Locality Name (eg, city) [Default City]:shaaxi
Organization Name (eg, company) [Default Company Ltd]:xian #组织
Organizational Unit Name (eg, section) []:peihua #组织单位
Common Name (eg, your name or your servers hostname) []:www.hehe.com #给证书的域名
Email Address []:anminhehe.com #邮箱
5.修改ssh.conf配置文件内容如下
[rootlocalhost certs]# vim /etc/httpd/conf.d/ssl.conf
#将密钥文件的目录改一下
SSLCertificateFile /etc/pki/tls/certs/jiami.crt
SSLCertificateKeyFile /etc/pki/tls/private/jiami.key
注意在配置文件中找到这两行修改一下就行不用修改其他的内容
6.关闭防火墙重启服务
[rootlocalhost certs]# systemctl stop firewall.server
[rootlocalhost certs]# systemctl restart httpd
7.浏览器访问查看证书
https://www.hehe.com/
8.如果要显示hehe页面内容需要单独为这个虚拟主机配置如下
[rootlocalhost conf.d]# vim vhost.conf
directory /www
allowoverride none
require all granted
/directoryvirtualhost 192.168.54.131:443 #端口要改为443
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/jiami.crt
SSLCertificateKeyFile /etc/pki/tls/private/jiami.key
documentroot /www/hehe
servername www.hehe.com
alias /hehe /usr/local/mysecret
/virtualhost 重启服务就可以了systemctl restart