站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
▼
建站程序
开发
服务器
办公软件
开发教程
▼
服务器教程
软件使用教程
运营教程
热门电子书
▼
CSS教程
WordPress教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
热点词条
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
CentOS/让服务器支持安全HTTP协议
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
{{CentOS top}} 在我们通常用<nowiki>“http://”</nowiki>这样的方式来访问[[网站]]的时候,传输内容是可能被别人截获的,因为其内容是通过明文传输,所以在传递一些隐私、以及密码相关的信息时,就显得非常的不安全。在一些比较正式的网站、以及一些银行相关的网站中,一些需要提交隐私或者重要级别比较高的密码时,都采用<nowiki>“https://”</nowiki>的方式,来将传输内容加密,从而保证用户安全和避免隐私的泄漏。 在这里,我们通过mod_ssl来使我们的[[服务器]]也支持HTTPS。 ==安装mod_ssl== 首先通过yum来在线安装mod_ssl。 <pre>[root@sample html]# yum -y install mod_ssl ← 在线安装mod_ssl Setting up Install Process Setting up repositories Reading repository metadata in from local files Reducing Dag RPM Repository for Red Hat Enterprise Linux to included packages only Finished Parsing package install arguments Resolving Dependencies --> Populating transaction set with selected packages. Please wait. ---> Downloading header for mod_ssl to pack into transaction set. mod_ssl-2.0.52-28.ent.cen 100% |=========================| 25 kB 00:00 ---> Package mod_ssl.i386 1:2.0.52-28.ent.centos4 set to be updated --> Running transaction check --> Processing Dependency: libnal.so.1 for package: mod_ssl --> Processing Dependency: libdistcache.so.1 for package: mod_ssl --> Restarting Dependency Resolution with new changes. --> Populating transaction set with selected packages. Please wait. ---> Downloading header for distcache to pack into transaction set. distcache-1.4.5-6.i386.rp 100% |=========================| 7.2 kB 00:00 ---> Package distcache.i386 0:1.4.5-6 set to be updated --> Running transaction check Dependencies Resolved ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: mod_ssl i386 1:2.0.52-28.ent.centos4 base 98 k Installing for dependencies: distcache i386 1.4.5-6 base 111 k Transaction Summary ============================================================================= Install 2 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 209 k Downloading Packages: (1/2): distcache-1.4.5-6. 100% |=========================| 111 kB 00:00 (2/2): mod_ssl-2.0.52-28. 100% |=========================| 98 kB 00:00 Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: distcache ######################### [1/2] Installing: mod_ssl ######################### [2/2] Installed: mod_ssl.i386 1:2.0.52-28.ent.centos4 Dependency Installed: distcache.i386 0:1.4.5-6 Complete!</pre> ==为HTTP服务器配置mod_ssl== [1] 建立服务器密钥 <pre>[root@sample conf]# cd /etc/httpd/conf ← 进入HTTP服务器配置文件所在目录 [root@sample conf]# rm -f ssl.*/server.* ← 删除默认或残留的服务器证书相关文件 [root@sample conf]# make genkey ← 建立服务器密钥 umask 77 ; \ /usr/bin/openssl genrsa -des3 1024 > /etc/httpd/conf/ssl.key/server.key Generating RSA private key, 1024 bit long modulus ................++++++ ....................................................................++++++ e is 65537 (0x10001) Enter pass phrase: ← 在这里输入口令 Verifying - Enter pass phrase: ← 确认口令,再次输入 [root@sample conf]# openssl rsa -in ssl.key/server.key -out ssl.key/server.key ← 从密钥中删除密码(以避免系统启动后被询问口令) Enter pass phrase for ssl.key/server.key: ← 输入口令 writing RSA key </pre> [2] 建立服务器公钥 <pre>[root@sample conf]# make certreq ← 建立服务器密钥 umask 77 ; \ /usr/bin/openssl req -new -key /etc/httpd/conf/ssl.key/server.key -out /etc/httpd/conf/ssl.csr/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) [GB]:CN ← 输入国名 State or Province Name (full name) [Berkshire]:Heilongjiang ← 输入省名 Locality Name (eg, city) [Newbury]:Harbin ← 输入城市名 Organization Name (eg, company) [My Company Ltd]:www.centospub.com ← 输入组织名(任意) Organizational Unit Name (eg, section) []: ← 不输入,直接回车 Common Name (eg, your name or your server's hostname) []:www.centospub.com ← 输入通称(任意) Email Address []:yourname@yourserver.com ← 输入电子邮箱地址 Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: ← 不输入,直接回车 An optional company name []: ← 不输入,直接回车</pre> [3] 建立服务器证书 <pre>[root@sample conf]# openssl x509 -in ssl.csr/server.csr -out ssl.crt/server.crt -req -signkey ssl.key/server.key -days 365 ← 建立服务器证书 Signature ok subject=/C=CN/ST=Heilongjiang/L=Harbin/O= www.centospub.com/CN=www.centospub.com/emailAddress=yourname@yourserver.com Getting Private key</pre> [4] 设置[[SSL]] <pre>[root@sample conf]# vi /etc/httpd/conf.d/ssl.conf ← 修改SSL的设置文件 #DocumentRoot "/var/www/html" ← 找到这一行,将行首的“#”去掉 ↓ DocumentRoot "/var/www/html" ← 变为此状态</pre> [5] 重新启动HTTP服务器,让SSL生效 <pre>[root@sample conf]# /etc/rc.d/init.d/httpd restart ← 重新启动HTTP服务器 Stopping httpd: [ OK ] Starting httpd: [ OK ]</pre> [6] 设置[[防火墙]]允许SSL <pre>[root@sample conf]# vi /etc/sysconfig/iptables ← 编辑防火墙配置文件 -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT ← 找到这一行,接着添加如下行: -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT ← 开放443号端口,允许SSL [root@sample conf]# /etc/rc.d/init.d/iptables restart ← 重新启动防火墙,使设置生效 Flushing firewall rules: [ OK ] Setting chains to policy ACCEPT: filter [ OK ] Unloading iptables modules: [ OK ] Applying iptables firewall rules: [ OK ]</pre> ==测试SSL== 可以通过自用PC来测试SSL。打开[[浏览器]],在地址栏输入<nowiki>“https://服务器IP地址”</nowiki>或者<nowiki>“https://你的域名”</nowiki>后,如果出现提示安装服务器证明书的窗口(图样如下),说明服务器已经支持SSL。 [[Image:Sslcli.gif]] 这时,如果选择“永远接受此证书”,然后点击确定后,再次通过HTTPS协议访问该站点,将不会再弹出此窗口提示安装服务器证书。 ==参考来源== http://www.centospub.com/make/ssl.html {{CentOS}} [[category:CentOS|R]]
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)
本页使用的模板:
模板:CentOS
(
编辑
)
模板:CentOS top
(
编辑
)