Linux 下 apache 配置 ssl
apache2.0https
首先安装SSL,再编译安装APACHE,再配置证书即可
1.下载apache和openssl
网址:http://www.apache.org
http://www.openssl.org
2.解压
#tarzxvfhttpd-2.2.21.tar.gz
#tarzxvfopenssl-0.9.7g.tar.gz
3.编译安装openssl,这个软件主要是用来生成证书:
#cdopenssl-0.9.7g
#./config
#make
#maketest
#makeinstall
openssl目录下.
#cd/usr/local/bin
/usr/local/ssl/bin/openssl
yuminstallopenssl-devel
4.编译安装apache
#cd/opt/httpd-2.0.54
#./configure--prefix="/usr/local/apache2"--enable-so--enable-ssl--with-ssl="/usr/local/ssl/bin"
#make
#makeinstall
5.安装完毕,生成证书:
在/usr/local/apache2/conf下建立一个ssl.key目录
#cd../apache2/
#cdconf/
#mkdirssl.key
然后在该目录下生成证书:
#cdssl.key/
生成服务器私钥:
#opensslgenrsa-des3-outserver.key1024
GeneratingRSAprivatekey,1024bitlongmodulus
.......................++++++
.................................................++++++
eis65537(0x10001)
Enterpassphraseforserver.key:
Verifying-Enterpassphraseforserver.key:
生成服务器证书请求,并按要求填些相关证书信息:
#opensslreq-new-keyserver.key-outserver.csr
Enterpassphraseforserver.key:
Youareabouttobeaskedtoenterinformationthatwillbeincorporated
intoyourcertificaterequest.
WhatyouareabouttoenteriswhatiscalledaDistinguishedNameoraDN.
Therearequiteafewfieldsbutyoucanleavesomeblank
Forsomefieldstherewillbeadefaultvalue,
Ifyouenter'.',thefieldwillbeleftblank.
-----
CountryName(2lettercode)[AU]:
StateorProvinceName(fullname)[Some-State]:
LocalityName(eg,city)[]:tyl
OrganizationName(eg,company)[InternetWidgitsPtyLtd]:tz
OrganizationalUnitName(eg,section)[]:tz
CommonName(eg,YOURname)[]:tyl
EmailAddress[]:[email protected]
Pleaseenterthefollowing'extra'attributes
tobesentwithyourcertificaterequest
Achallengepassword[]:
Anoptionalcompanyname[]:
签证:
#opensslx509-req-days700-inserver.csr-signkeyserver.key-outserver.cert
Signatureok
subject=/C=AU/ST=Some-State/L=tyl/O=tz/OU=tz/CN=tyl/[email protected]
GettingPrivatekey
Enterpassphraseforserver.key:
为了安全,然后我们把这些文件的权限都设为400
chmod400server.key
chmod400server.cert
最后对/usr/local/apache2/conf/extra/httpd-ssl.conf进行修改:
#SSLCertificateFile/opt/apache2/conf/ssl.crt/server.crt#108行
SSLCertificateFile/opt/apache2/conf/ssl.key/server.cert
#SSLCertificateFile/opt/apache2/conf/ssl.crt/server-dsa.crt
SSLCertificateKeyFile/opt/apache2/conf/ssl.key/server.key#116行
#SSLCertificateKeyFile/opt/apache2/conf/ssl.key/server-dsa.key
这样我们就基本配好了ssl现在我们来让apache启动ssl
6.修改httpd.conf
enable
includeconf/extra/httpd-ssl.conf
/opt/apache2/bin/apachectlstart
然后要求输入证书密码,正确输入后ssl就连同apache一起启动
在浏览器中输入:https://210.75.18.36