1.yum 安装openssl和openssl-devel,httpd-devel expat-devel
2.安装gcc、gcc-c++ apr apr-util pcre httpd
如果版本之间不匹配,安装过程中会出现问题。
https://www.cnblogs.com/wcwnina/p/8029156.html
3.生成相关证书
yum install mod_ssl
cd /etc/pki/CA
1.生成2048位的加密私钥
openssl genrsa -out server.key 2048
2.生成证书签名请求
openssl req -new -key server.key -out server.csr
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]:CN
State or Province Name (full name) []:beijing
Locality Name (eg, city) [Default City]:beijing
Organization Name (eg, company) [Default Company Ltd]:test.com
Organizational Unit Name (eg, section) []:test
Common Name (eg, your name or your server's hostname) []:test.com
Email Address []:test@qq.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:test
3.生成类型为X509的自签名证书(有效期36500天)
openssl x509 -req -days 36500 -in server.csr -signkey server.key -out server.crt
4.相关配置文件修改
1.修改ssl.conf
vim /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/pki/CA/server.crt
SSLCertificateKeyFile /etc/pki/CA/server.key
DocumentRoot "/var/www/html"(去掉行首的注释)
ServerName www.test.com (去掉行首的注释)
2.修改Apache的配置文件httpd.conf
vim usr/local/apache/conf httpd.conf
LoadModule ssl_module modules/mod_ssl.so (去掉行首的注释)
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so (去掉行首的注释)
Include conf/extra/httpd-ssl.conf (去掉行首的注释)