如何为 Apache httpd 安装 mod_ssl?
好的
,我不久前安装了 Apache httpd
,最近又回来尝试设置 SSL 并让它为多个不同的 tomcat 服务器提供服务。
目前,我有两个完全独立的 Tomcat 实例,为两个不同的端口提供稍微不同的版本(一个用于开发,一个用于演示),我的 Web 应用程序:
example.com:8081
example .com:8082
我已经成功(早在一月份)使用 mod_jk
获取 httpd
来为 http:// 提供相同的 Tomcat 实例www.example.com:8090/dev
和 http://www.example.com:8090/demo
(8090 因为我有另一个应用程序通过 Jetty 在 8080 上运行阶段)在 httpd.conf
中使用以下代码:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel debug
<VirtualHost *:8090>
JkMount /devd* tomcatDev
JkMount /demo* tomcatDemo
</VirtualHost>
我不想做的是启用 SSL。
我已将以下内容添加到 httpd.conf
中:
Listen 443
<VirtualHost _default_:443>
JkMount /dev* tomcatDev
JkMount /demo* tomcatDemo
SSLEngine on
SSLCertificateFile "/opt/httpd/conf/localhost.crt"
SSLCertificateKeyFile "/opt/httpd/conf/keystore.key"
</VirtualHost>
但是当我尝试使用 apachectl restart
重新启动 Apache 时(是的,在关闭我提到的其他应用程序后,它不会带有 https 连接的玩具)我不断收到错误:
命令“SSLEngine”无效,可能拼写错误或由未包含在服务器配置中的模块定义。 httpd 未运行,正在尝试启动
我查看了 httpd/modules
目录,确实没有 mod_ssl
,只有 mod_jk.so
和httpd.exp
。
我尝试使用 yum 安装 mod_ssl
,它说它已经安装了。事实上,我可以在 /usr/lib/httpd/modules
中找到 mod_ssl.so
,但这不是我安装 httpd
的路径这是 /opt/httpd
,事实上 /usr/lib/httpd
只包含 modules
目录。
谁能告诉我如何为我的 httpd
安装位置正确安装 mod_ssl
以便我可以克服此错误?
Ok
So I installed Apache httpd
a while ago and have recently come back to it to try setup SSL and get it serving several different tomcat servers.
At the moment I have two completely separate Tomcat instances serving up to slightly different versions (one for dev and one for demo say) my web app to two different ports:
example.com:8081
example.com:8082
I've successfully (back in Jan) used mod_jk
to get httpd
to serve those same Tomcat instances to http://www.example.com:8090/dev
and http://www.example.com:8090/demo
(8090 cos I've got another app running on 8080 via Jetty at this stage) using the following code in httpd.conf
:
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel debug
<VirtualHost *:8090>
JkMount /devd* tomcatDev
JkMount /demo* tomcatDemo
</VirtualHost>
What I'm not trying to do is enable SSL.
I've added the following to httpd.conf
:
Listen 443
<VirtualHost _default_:443>
JkMount /dev* tomcatDev
JkMount /demo* tomcatDemo
SSLEngine on
SSLCertificateFile "/opt/httpd/conf/localhost.crt"
SSLCertificateKeyFile "/opt/httpd/conf/keystore.key"
</VirtualHost>
But when I try to restart Apache with apachectl restart
(yes after shutting down that other app I mentioned so it doesn't toy with https connections) I continuously get the error:
Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration. httpd not running, trying to start
I've looked in the httpd/modules
dir and indeed there is no mod_ssl
, only mod_jk.so
and httpd.exp
.
I've tried using yum to install mod_ssl
, it says its already installed. Indeed I can locate mod_ssl.so
in /usr/lib/httpd/modules
but this is NOT the path to where I've installed httpd
which is /opt/httpd
and in fact /usr/lib/httpd
contains nothing but the modules
dir.
Can anyone tell me how to install mod_ssl
properly for my installed location of httpd
so I can get past this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我发现我需要在 Apache 中启用 SSL 模块(如果您不是以 root 身份运行,显然需要在命令前加上 sudo 前缀):
然后重新启动 Apache:
More details of SSL in Apache for Ubuntu / Debian 此处。
I found I needed to enable the SSL module in Apache (obviously prefix commands with
sudo
if you are not running as root):then restart Apache:
More details of SSL in Apache for Ubuntu / Debian here.
是否还有其他
LoadModule
命令引用/usr/lib/httpd/modules
文件夹中的模块?如果是这样,您只需将 LoadModule ssl_module /usr/lib/httpd/modules/mod_ssl.so 添加到您的conf 文件中就可以了。否则,您需要将 mod_ssl.so 文件复制到加载其他模块的目录并在那里引用它。
Are any other
LoadModule
commands referencing modules in the/usr/lib/httpd/modules
folder? If so, you should be fine just addingLoadModule ssl_module /usr/lib/httpd/modules/mod_ssl.so
to your conf file.Otherwise, you'll want to copy the
mod_ssl.so
file to whatever directory the other modules are being loaded from and reference it there.尝试使用以下命令安装 mod_ssl:
然后使用以下命令重新加载并重新启动 Apache 服务器:
这应该适用于大多数情况。
Try installing
mod_ssl
using following command:and then reload and restart your Apache server using following commands:
This should work for most of the cases.
我使用过:
并且它在我的 Amazon Linux AMI 中工作。
I used:
and it worked in my Amazon Linux AMI.
我不知道它是否仍然令人感兴趣,也不知道自从该线程发布以来事情是否发生了变化,但我系统上的
/etc/apache2/apache2.conf
说:在我的系统上,模块安装在 /usr/lib/apache2/modules 中。
我正在运行 Ubuntu 20.04.2 LTS。
I don't know if it is still of interest and if things have changed ever since the thread has been posted, but the
/etc/apache2/apache2.conf
on my system says:And on my system the modules are installed in /usr/lib/apache2/modules.
I am running Ubuntu 20.04.2 LTS.