RPM 方式是apache支持https。。。
# yum install mod-ssl
生成服务器私钥:
# openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
.......................++++++
.................................................++++++
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
生成服务器证书请求,并按要求填些相关证书信息:
#openssl req -new -key server.key -out server.csr
Enter pass phrase for server.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) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:tyl
Organization Name (eg, company) [Internet Widgits Pty Ltd]:tz
Organizational Unit Name (eg, section) []:tz
Common Name (eg, YOUR name) []:tyl
Email Address []:tangyl@ruyi.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
签证:
# openssl x509 -req -days 700 -in server.csr -signkey server.key -out server.cert
Signature ok
subject=/C=AU/ST=Some-State/L=tyl/O=tz/OU=tz/CN=tyl/emailAddress=tangyl@ruyi.com
Getting Private key
Enter pass phrase for server.key:
为了安全,然后我们把这些文件的权限都设为400
chmod 400 server.key
chmod 400 server.cert
最后对/opt/apache2/conf/ssl.conf 进行修改:
vi /opt/apache2/conf/ssl.conf
修改的地方如下几处:
#SSLCertificateFile .../server.crt #108行
SSLCertificateFile .../server.cert
#SSLCertificateFile .../server-dsa.crt
修改的地方如下几处:
#SSLCertificateFile .../server.crt #108行
SSLCertificateFile .../server.cert
#SSLCertificateFile .../server-dsa.crt
SSLCertificateKeyFile .../server.key #116行
#SSLCertificateKeyFile /opt/apache2/conf/ssl.ke
#SSLCertificateKeyFile /opt/apache2/conf/ssl.ke
service httpd restart
输入密码后 http与https 同时启动。
#netstat -ntpl
tcp 0 0 :::80 :::* LISTEN 24805/httpd
tcp 0 0 :::22 :::* LISTEN 3180/sshd
tcp 0 0 :::443 :::* LISTEN 24805/httpd
tcp 0 0 :::22 :::* LISTEN 3180/sshd
tcp 0 0 :::443 :::* LISTEN 24805/httpd
https即可 访问
参考
转载于:https://blog.51cto.com/engtt/345383