CentOS下httpd 2.4.7配置https

简介:

通过http协议传输的数据都是明文的,很容易被窃听。很多时候需要在网上传输口令,这个时候就需要对信息进行加密,对HTTP传输进行加密的协议就是HTTPS,它是通过SSL进行HTTP传输的协议。

我们现在已经有了httpd环境,可参考(http://fengwan.blog.51cto.com/508652/1360429)

在编译过程中需要加上参数--enable-ssl

[root@NFSServer httpd-2.4.7] # ./configure \
>--prefix= /webserver/httpd \
>--sysconfdir= /webserver/httpd/conf \
>-- enable -so \
>-- enable -rewirte \
>--enable-ssl \
>-- enable -cgi \
>-- enable -cgid \
>-- enable -modules=most \
>-- enable -modules-shared=most \
>-- enable -mpms-shared=all \
>--with-apr= /webserver/apr \
>--with-apr-util= /webserver/apr-util


1.环境准备

1.openssl安装

1
[root@WebServer ~] # yum -y install openssl openssl-devel

2.创建密码文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@WebServer ~] # openssl genrsa -out server.key 1024
[root@WebServer ~] # 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) []:GuangDong
Locality Name (eg, city) [Default City]:GuangZhou
Organization Name (eg, company) [Default Company Ltd]:Test
Organizational Unit Name (eg, section) []:Test
Common Name (eg, your name or your server's  hostname ) []:localhost
Email Address []:ca
Please enter the following  'extra'  attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
[root@WebServer ~] # openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt

执行上述命令后将产生3个文件,分别是server.key、server.csr和server.crt ,接着将3个文件复制到/webserver/httpd/conf/ca

1
2
[root@WebServer ~] # mkdir /webserver/httpd/conf/ca/
[root@WebServer ~] # cp -r server.* /webserver/httpd/conf/ca/

3.修改 /webserver/httpd/conf/extra/httpd-ssl.conf

1
2
3
4
[root@WebServer ~] # vim /webserver/httpd/conf/extra/httpd-ssl.conf
// 修改一下位置
SSLCertificateFile  "/webserver/httpd/conf/ca/server.crt"
SSLCertificateKeyFile  "/webserver/httpd/conf/ca/server.key"

4.修改/webserver/httpd/conf/httpd.conf加载ssl_module和socache_shmcb_module

1
2
3
4
[root@WebServer ~] # vim /webserver/httpd/conf/httpd.conf
// 将一下2句前面的 #删除,或者直接将下面这2句加入配置文件
LoadModule socache_shmcb_module modules /mod_socache_shmcb .so
LoadModule ssl_module modules /mod_ssl .so

如果没有加载socache_shmcb_module将出现

1
2
3
4
5
[root@WebServer ~] # service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: AH00526: Syntax error on line 76 of  /webserver/httpd/conf/extra/httpd-ssl .conf:
SSLSessionCache:  'shmcb'  session cache not supported (known names: ). Maybe you need to load the appropriate socache module (mod_socache_shmcb?).
                                                            [FAILED]

5.重启httpd服务即可

1
2
3
[root@WebServer ~] # service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

6.测试

wKiom1MNoP3z_0uvAACCEvxM3ME471.png


本文转自 rong341233 51CTO博客,原文链接:http://blog.51cto.com/fengwan/1363821


相关文章
|
5月前
|
人工智能 Ubuntu 前端开发
Dify部署全栈指南:AI从Ubuntu配置到HTTPS自动化的10倍秘籍
本文档介绍如何部署Dify后端服务及前端界面,涵盖系统环境要求、依赖安装、代码拉取、环境变量配置、服务启动、数据库管理及常见问题解决方案,适用于开发与生产环境部署。
1234 1
|
9月前
|
应用服务中间件 Linux 网络安全
Centos 8.0中Nginx配置文件和https正书添加配置
这是一份Nginx配置文件,包含HTTP与HTTPS服务设置。主要功能如下:1) 将HTTP(80端口)请求重定向至HTTPS(443端口),增强安全性;2) 配置SSL证书,支持TLSv1.1至TLSv1.3协议;3) 使用uWSGI与后端应用通信(如Django);4) 静态文件托管路径设为`/root/code/static/`;5) 定制错误页面(404、50x)。适用于Web应用部署场景。
892 87
|
4月前
|
网络安全 开发工具 git
在GitLab CI中同步HTTPS仓库地址的yaml配置
最后,提交并推送 `.gitlab-ci.yml`文件到您的GitLab仓库。GitLab CI/CD将自动识别这个文件,并在每次推送到 `master`分支时执行定义的同步任务。
240 16
|
7月前
|
存储 Linux Apache
在CentOS上配置SVN至Web目录的自动同步
通过上述配置,每次当SVN仓库中提交新的更改时,`post-commit`钩子将被触发,SVN仓库的内容会自动同步到指定的Web目录,从而实现代码的连续部署。
224 16
|
7月前
|
NoSQL 安全 Linux
设置Redis在CentOS7上的自启动配置
这些步骤总结了在CentOS 7系统上设置Redis服务自启动的过程。这些命令提供了一个直接且明了的方式,确保Redis作为关键组件在系统启动时能自动运行,保障了依赖于Redis服务的应用的稳定性和可用性。
595 9
|
9月前
|
Ubuntu 安全 Linux
CentOS与Ubuntu中防火墙配置命令集汇
有了这些,你就能遨游在 CentOS 和 Ubuntu 的海洋中,频繁地改变你的防火墙设置,快速地应对各种安全威胁,同时也能保证你的系统可以正常工作。出发吧,勇敢的编程者,随着这些命令集的涌动,扬帆起航,走向安全的网络世界!
317 5
|
应用服务中间件 Linux 网络安全
|
9月前
|
安全 网络协议 Linux
Linux网络应用层协议展示:HTTP与HTTPS
此外,必须注意,从HTTP迁移到HTTPS是一项重要且必要的任务,因为这不仅关乎用户信息的安全,也有利于你的网站评级和粉丝的信心。在网络世界中,信息的安全就是一切,选择HTTPS,让您的网站更加安全,使您的用户满意,也使您感到满意。
262 18
|
9月前
|
网络安全 开发者
如何解决HTTPS协议在WordPress升级后对网站不兼容的问题
以上就是解决WordPress升级后HTTPS协议对网站的不兼容问题的方法。希望能把这个棘手的问题看成是学校的管理问题一样来应对,将复杂的技术问题变得更加有趣和形象,并寻觅出解决问题的方式。希望你的网站能在新的学期得到更好的发展!
252 19