LINUX

首页 -  LINUX  -  Linux apach生成Https链接(自定义签名)

Linux apach生成Https链接(自定义签名)

当我们需要用https协议来访问网站的时候我们就需要生成证书和秘钥下面为大家介绍一种自定义签名方法:


1.检查apache是否开启了ssl模块 

cd /etc/httpd/conf.d/

ls

查看是否有ssl.conf配置文件如果没有就说明没有安装

或者

cd /etc/httpd/modules

查看是不是有mod_ssl.so模块如果没有就说明没有安装


以上2种方法可查看是否开启了ssl

 

2.如果没有ssl那么就需要安装ssl模块

yum install mod_ssl openssl 

安装完成后 

cd /etc/httpd/conf.d/

这里面就会生成 ssl.conf 文件


3.生成认证

步骤1:生成密钥

进入apache配置文件 cd /etc/httpd/conf/

命令:openssl genrsa 1024 > server.key

说明:这是用128位rsa算法生成密钥,得到server.key文件

步骤2: 生成证书请求文件

命令:openssl req -new -key server.key > server.csr

说明:这是用步骤1的密钥生成证书请求文件server.csr, 这一步提很多问题,根据你自己来填写证书信息

CountryName(2lettercode)[AU]:US
StateorProvinceName(fullname)[Some-State]:NewYork
LocalityName(eg,city)[]:NewYorkCity
OrganizationName(eg,company)[InternetWidgitsPtyLtd]:YourCompany
OrganizationalUnitName(eg,section)[]:DepartmentofKittens
CommonName(e.g.serverFQDNorYOURname)[]:your_domain.com
EmailAddress[]:your_email@domain.com

步骤3: 生成证书

命令:openssl req -x509 -days 365 -key server.key -in server.csr > server.crt

说明:这是用步骤1,2的的密钥和证书请求生成证书server.crt,-days参数指明证书有效期,单位为天


4.配置httpd conf.d  下的 ssl.conf

注意在此文件中配置证书和密钥

SSLCertificateFile /etc/httpd/conf/server.crt

SSLCertificateKeyFile /etc/httpd/conf/server.key 


#配置项目目录和域名

DocumentRoot "/var/lib/jenkins/jobs/wx"

ServerName testssl.com


5.如果你的443端口没有加入防火墙请先设置443端口

vim /etc/sysconfig/iptables

#追加443端口
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT

#重启
/etc/init.d/iptables restart


防火墙详细设置参考:http://www.xiaoshu168.com/linux/37.html


6.配置完成你可以访问了 https://127.0.1/index.php


(0)
分享:

本文由:xiaoshu168 作者:xiaoshu发表,转载请注明来源!

标签:

相关阅读