如何为 Apache httpd 安装 mod_ssl?

发布于 2024-10-20 23:08:20 字数 1759 浏览 2 评论 0原文

好的

,我不久前安装了 Apache httpd,最近又回来尝试设置 SSL 并让它为多个不同的 tomcat 服务器提供服务。

目前,我有两个完全独立的 Tomcat 实例,为两个不同的端口提供稍微不同的版本(一个用于开发,一个用于演示),我的 Web 应用程序:

  • example.com:8081
  • example .com:8082

我已经成功(早在一月份)使用 mod_jk 获取 httpd 来为 http:// 提供相同的 Tomcat 实例www.example.com:8090/devhttp://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.sohttpd.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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

十二 2024-10-27 23:08:20

我发现我需要在 Apache 中启用 SSL 模块(如果您不是以 root 身份运行,显然需要在命令前加上 sudo 前缀):

a2enmod ssl

然后重新启动 Apache:

/etc/init.d/apache2 restart

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):

a2enmod ssl

then restart Apache:

/etc/init.d/apache2 restart

More details of SSL in Apache for Ubuntu / Debian here.

_畞蕅 2024-10-27 23:08:20

是否还有其他 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 adding LoadModule 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.

じ违心 2024-10-27 23:08:20

尝试使用以下命令安装 mod_ssl:

yum install mod_ssl

然后使用以下命令重新加载并重新启动 Apache 服务器:

systemctl reload httpd.service
systemctl restart httpd.service

这应该适用于大多数情况。

Try installing mod_ssl using following command:

yum install mod_ssl

and then reload and restart your Apache server using following commands:

systemctl reload httpd.service
systemctl restart httpd.service

This should work for most of the cases.

层林尽染 2024-10-27 23:08:20

我使用过:

sudo yum install mod24_ssl

并且它在我的 Amazon Linux AMI 中工作。

I used:

sudo yum install mod24_ssl

and it worked in my Amazon Linux AMI.

舂唻埖巳落 2024-10-27 23:08:20

我不知道它是否仍然令人感兴趣,也不知道自从该线程发布以来事情是否发生了变化,但我系统上的 /etc/apache2/apache2.conf 说:

mods-enabled/、conf-enabled/ 和sites-enabled/ 中的配置文件
目录包含管理模块的特定配置片段,
全局配置片段,或虚拟主机配置,
分别。

它们是通过从它们的符号链接可用配置文件来激活的
相应的*-可用/对应项。这些应该通过使用我们的
帮助程序 a2enmod/a2dismod、a2ensite/a2dissite 和 a2enconf/a2disconf。看
他们各自的手册页以获取详细信息。

在我的系统上,模块安装在 /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:

Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
directories contain particular configuration snippets which manage modules,
global configuration fragments, or virtual host configurations,
respectively.

They are activated by symlinking available configuration files from their
respective *-available/ counterparts. These should be managed by using our
helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
their respective man pages for detailed information.

And on my system the modules are installed in /usr/lib/apache2/modules.
I am running Ubuntu 20.04.2 LTS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文