rocky Linux 8 apache 安装ssl证书
时间: 2024-03-16 18:16:23 浏览: 16
安装 SSL 证书需要以下步骤:
1. 安装 Apache
如果你还没有安装 Apache,请先安装。
```shell
sudo dnf install httpd
```
2. 安装 OpenSSL
```shell
sudo dnf install openssl
```
3. 生成 SSL 证书
在生成 SSL 证书之前,确保你已经为你的域名配置了 DNS 解析。
使用 OpenSSL 工具生成 SSL 证书:
```shell
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/pki/tls/private/example.com.key -out /etc/pki/tls/certs/example.com.crt
```
注意:将 example.com 替换为你的域名。
4. 配置 Apache
打开 Apache 的 SSL 配置文件 `/etc/httpd/conf.d/ssl.conf`。
```shell
sudo nano /etc/httpd/conf.d/ssl.conf
```
找到以下行并取消注释:
```
SSLCertificateFile /etc/pki/tls/certs/example.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/example.com.key
```
注意:将 example.com 替换为你的域名。
5. 重启 Apache
```shell
sudo systemctl restart httpd
```
现在你已经成功安装了 SSL 证书并启用了 HTTPS。