How to install mod_ssl for Apache httpd?
Asked Answered
C

5

91

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?

Carangid answered 10/3, 2011 at 9:55 Comment(0)
G
43

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.

Galactic answered 10/3, 2011 at 14:18 Comment(3)
In my Apache installation mod_ssl.so was outright missing. Turns out its separate from the base installation and was under the package mod_ssl in the yum package manger. Downloaded using yum install mod_ssl then it appeared in the modules folder.Quenna
I found, after compiling my own apache 2 that mod_ssl.so was missing. need to compile it again, from scratch.Launcher
@Quenna thanks, I confirm that after installing the module it included the module and also added a ssl.conf file that has the needed configurations.Nestle
T
126

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.

Tiossem answered 26/6, 2013 at 12:0 Comment(2)
Which distribution OS are u using?Hoopoe
@Hoopoe a2enmod is from the Debian world.Psychro
G
43

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.

Galactic answered 10/3, 2011 at 14:18 Comment(3)
In my Apache installation mod_ssl.so was outright missing. Turns out its separate from the base installation and was under the package mod_ssl in the yum package manger. Downloaded using yum install mod_ssl then it appeared in the modules folder.Quenna
I found, after compiling my own apache 2 that mod_ssl.so was missing. need to compile it again, from scratch.Launcher
@Quenna thanks, I confirm that after installing the module it included the module and also added a ssl.conf file that has the needed configurations.Nestle
P
35

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.

Parous answered 5/10, 2016 at 12:20 Comment(1)
If you install Apache from source, then yum will not be able to detect it. Instead it will install a duplicate (outdated) version of Apache, and put mod_ssl.so in that Apache's module files.Numinous
Y
6

I used:

sudo yum install mod24_ssl

and it worked in my Amazon Linux AMI.

Yulan answered 27/11, 2018 at 3:53 Comment(0)
I
0

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.

Infamous answered 4/3, 2021 at 16:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.