147

When I restart httpd, I get the following error. What am I missing?

[root@localhost ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd: Syntax error on line 22 of /etc/httpd/conf.d/sites.conf:
Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration

I have installed mod_ssl using yum install mod_ssl openssh

Package 1:mod_ssl-2.2.15-15.el6.centos.x86_64 already installed and latest version
Package openssh-5.3p1-70.el6_2.2.x86_64 already installed and latest version

My sites.conf looks like this

<VirtualHost *:80>
#    ServerName shop.itmanx.com
    ServerAdmin [email protected]

    DocumentRoot /var/www/html/magento
    <Directory /var/www/html>
        Options -Indexes
        AllowOverride All
    </Directory>

    ErrorLog logs/shop-error.log
    CustomLog logs/shop-access.log
</VirtualHost>

<VirtualHost *:443>
    ServerName secure.itmanx.com
    ServerAdmin [email protected]

    SSLEngine on
    SSLCertificateFile /etc/httpd/ssl/secure.itmanx.com/server.crt
    SSLCertificateKeyFile /etc/httpd/ssl/secure.itmanx.com/server.key
    SSLCertificateChainFile /etc/httpd/ssl/secure.itmanx.com/chain.crt

    DocumentRoot /var/www/html/magento
    <Directory /var/www/html>
        Options -Indexes
        AllowOverride All
    </Directory>

    ErrorLog logs/shop-ssl-error.log
    CustomLog logs/shop-ssl-access.log    
</VirtualHost>
Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Christian
  • 2,155
  • 3
  • 16
  • 14

6 Answers6

179

On many systems (Ubuntu, Suse, Debian, ...) run the following command to enable Apache's SSL mod:

sudo a2enmod ssl

a2enmod man page

robsch
  • 169
  • 1
  • 2
  • 14
Stéphane
  • 1,910
  • 2
  • 11
  • 7
66

Probably you do not load the ssl module. You should have a LoadModule directive somewhere in your apache configuration files.

Something like:

LoadModule ssl_module /usr/lib64/apache2-prefork/mod_ssl.so

Usually apache configuration template has (on any distribution) a file called (something like) loadmodule.conf in which you should find a LoadModule directive for each module you load into apache at server start.

andcoz
  • 16,830
  • 3
  • 38
  • 45
  • 9
    Also, it's necessary to install `mod_ssl`. On RHEL and CentOS, this is done with `yum install mod_ssl`. – Benedikt Köppel Apr 18 '18 at 18:13
  • 2
    For Apache 2.4 it is yum install mod24_ssl – Alejandro Pablo Tkachuk Mar 14 '19 at 16:58
  • 12
    `sudo a2enmod ssl` – thoni56 Aug 09 '19 at 13:46
  • @AlejandroPabloTkachuk there is No package mod24_ssl available. For me just `yum install mod_ssl` worked perfectly. – vijay Nov 01 '19 at 22:46
  • 1
    @vijay the name of the package and how to enable it is _distribution dependent_. In addition, the package name can change in time. – andcoz Nov 04 '19 at 14:55
  • What's the advantage of having both http and https ? We have really to duplicate the virtual records twice just to change *:80 to *:443 lines? How to cause the browser to switch automatically to httpS when typing mydomain.com on the address bar? – Meryan Mar 22 '21 at 08:41
31

On CentOS 7 installing the package "mod_ssl" and restarting the apache server worked for me:

yum install mod_ssl
systemctl restart httpd
Falco Preiseni
  • 461
  • 4
  • 8
18

httpd24 solution:

yum install mod24_ssl
dtbarne
  • 300
  • 2
  • 7
3

On Ubntu 18.04 bionic.

sudo a2enmod ssl
sudo service apache2 restart
roaima
  • 107,089
  • 14
  • 139
  • 261
pumpkin_cat
  • 131
  • 2
  • 1
    The second answer already recomends `sudo a2enmod ssl;` Maybe you should add a comment there to restart the server after the change. –  Aug 15 '18 at 08:13
0

I received the same error while installing the SSL Certificate on my website. I have fixed it by executing the following command in the terminal.

# yum install mod_ssl
# httpd -t
# systemctl restart httpd

I am sure that the above commands will fix your error.