apache服务器开启https

 时间:2026-02-14 18:19:27

1、生成https证书,测试使用,正式使用需要购买

生成私钥文件  

sudo openssl genrsa -aes256 -out service.key 1024

然后按提示输入密码,文件生成成功

apache服务器开启https

2、生成证书文件并签署

sudo openssl req -sha256 -new -x509 -days 1826 -key service.key -out service.crt

估计提示输入相关信息

Common Name (e.g. server FQDN or YOUR name) []:这一项必须和你的域名一致

apache服务器开启https

3、配置apache,开启https

打开httpd.conf文件:

移除注释

LoadModule ssl_module libexec/apache2/mod_ssl.so

Include /private/etc/apache2/extra/httpd-vhosts.conf

apache服务器开启https

apache服务器开启https

4、修改httpd-vhosts.conf文件

修改DocumentRoot "/Users/xunao/website/upload" 为自己的网站路径

指定证书和密钥文件路径

SSLCertificateFile "/private/etc/apache2/server.crt"

SSLCertificateKeyFile "/private/etc/apache2/server.key"

apache服务器开启https

apache服务器开启https

5、重启apache

用 sudo apachectl configtest 检测配置文件是否有错误(windows为httpd -t)

sudo apachectl restart   (windows为httpd -k restart)

apache服务器开启https

6、访问网站:

https://域名

如果浏览器提示“您的连接不是私密连接”,则需安装证书的本地计算机

apache服务器开启https

  • VS中如何设置加粗所选选项卡上的文本
  • 怎么用bat执行java应用程序
  • Synchronizing has encoountered a problem?
  • 如何设置Excel始终以默认编码保存网页
  • 如何使用JavaScript中的函数返回值打印不同的值
  • 热门搜索
    刀鱼的做法 番茄牛肉的做法 蓼怎么读 鲍鱼做法大全 莲藕的做法 豆腐做法大全 鱼香茄子煲的做法 烤全羊的做法 蒜苗的做法大全 饼的做法