Linux—— 配置ssl安全证书

一、实验设计

二、实验配置过程

[student@bogon ~]$ su - root
Password:
[root@bogon ~]# dnf -y install nginx
[root@bogon ~]# vim /etc/selinux/config
[root@bogon ~]# setenforce 0
[root@bogon ~]# systemctl stop firewalld
清空防火墙规则
[root@bogon ~]# iptables -F ^C // 9之前
[root@bogon ~]# nft flush ruleset //9之后
[root@bogon ~]# systemctl disable firewalld
Removed "/etc/systemd/system/multi-user.target.wants/firewalld.service".
Removed "/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service".
[root@bogon ~]# systemctl ea
[root@bogon ~]# systemctl enable --now nginx.service
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service →
/usr/lib/systemd/system/nginx.service.
[root@bogon ~]# ps -elf | grep nginx
1 S root 7870 1 0 80 0 - 2810 sigsus 16:37 ?
00:00:00 nginx: master process /usr/sbin/nginx
5 S nginx 7871 7870 0 80 0 - 3891 ep_pol 16:37 ?
00:00:00 nginx: worker process
5 S nginx 7872 7870 0 80 0 - 3891 ep_pol 16:37 ?
00:00:00 nginx: worker process
0 R root 7874 6985 0 80 0 - 55450 - 16:38 pts/0
00:00:00 grep --color=auto nginx
[root@bogon ~]# cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf_$(date +%s)
[root@bogon ~]# vim /etc/nginx/nginx.conf
[root@bogon ~]# nginx -T

添加服务名称

生成日志文件和错误日志文件

[root@bogon ~]# ps -elf | grep nginx
1 S root 7870 1 0 80 0 - 2810 sigsus 16:37 ?
00:00:00 nginx: master process /usr/sbin/nginx
5 S nginx 7871 7870 0 80 0 - 3891 ep_pol 16:37 ?
00:00:00 nginx: worker process
5 S nginx 7872 7870 0 80 0 - 3891 ep_pol 16:37 ?
00:00:00 nginx: worker process
0 S root 8063 6985 0 80 0 - 55417 pipe_r 17:00 pts/0
00:00:00 grep --color=auto nginx
[root@bogon ~]# ps -elf | grep sshd
4 S root 1048 1 0 80 0 - 4181 do_sel 14:48 ?
00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
0 S root 8091 6985 0 80 0 - 55450 pipe_r 17:04 pts/0
00:00:00 grep --color=auto sshd
[root@bogon ~]# systemctl restart sshd
[root@bogon ~]# ps -elf | grep sshd
4 S root 8095 1 0 80 0 - 4181 do_sel 17:04 ?
00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
0 S root 8097 6985 0 80 0 - 55417 pipe_r 17:04 pts/0
00:00:00 grep --color=auto sshd
[root@bogon ~]# systemctl reload nginx
[root@bogon ~]# ps -elf | grep nginx
1 S root 7870 1 0 80 0 - 2842 sigsus 16:37 ?
00:00:00 nginx: master process /usr/sbin/nginx
5 S nginx 810
### 如何在 Linux 系统上安装和配置 SSL 证书 #### 使用 Let’s Encrypt 和 Certbot 在 CentOS 上为 Nginx 配置 SSL/TLS 证书 为了确保网站的安全性和可信度,在 CentOS 上为 Nginx 获取免费的 SSL/TLS 证书可以通过 Let's Encrypt 和 Certbot 实现。Certbot 是一个易于使用的工具,用于自动获取由 Let's Encrypt 提供的有效证书。 首先需要安装 Certbot 及其 Nginx 插件: ```bash sudo yum install epel-release sudo yum install certbot python2-certbot-nginx ``` 完成上述软件包的安装之后,可以运行命令来获得证书并设置自动化更新过程[^1]。 对于全新部署的 Linux 服务器而言,还需要预先准备好一些开发库文件以便后续操作顺利进行: ```bash yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel ``` 这些依赖项有助于构建必要的组件和支持 HTTPS 协议所需的加密算法支持[^2]。 #### Apache 下 SSL 的启用方法 针对采用 Apache HTTP Server 的情况,则需先加载 `mod_ssl` 模块以激活对 SSL 连接的支持。这一步骤通常涉及编辑 httpd.conf 或者 ssl.conf 文件,并确认如下指令存在且未被注释掉: ```apache LoadModule ssl_module modules/mod_ssl.so Include conf/extra/httpd-ssl.conf ``` 接着按照指引上传购买得到或是自签名制作而成的私钥(.key)与公钥证书链文件(.crt),调整 VirtualHost 设置指向正确的路径即可[^3]。 #### Tomcat 中集成 SSL 支持的方式 当目标应用容器是 Apache Tomcat 时,同样要引入 JSSE (Java Secure Socket Extension) 库来进行安全通信层管理。具体来说就是修改 server.xml 来定义 Connector 组件属性,指定 keystoreFile 参数关联到已有的 .jks 格式的密钥仓库位置;同时设定相应的密码保护措施防止未经授权访问敏感数据[^4]。 综上所述,不同类型的 Web 服务程序有着各自特定的方式来处理 SSL 证书事宜,但总体流程大同小异——即准备环境、申请或生成凭证资料、最后依照官方文档指示逐步实施直至成功开启 HTTPS 访问模式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值