Error Running Client: Expected </VirtualHost> but saw </VirtualHost></IfModule>

I can only suggest -vvv on the command line and seeing if that provides some extra clues.

Tried that, It scrolled through a bunch of normal logs, but once it started the ui, it went to quickly to read and there is no way to scroll up inside the ui.

Anything in the apache log ?

You can also use the --text option to remove the GUI - then you should be able to scroll.

Everything above whats pasted bellow seems normal, and there is nothing in /var/log/apache2/error.log…

2015-12-19 15:33:50,450:DEBUG:letsencrypt.error_handler:Encountered exception:
Traceback (most recent call last):
  File "/home/terra/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/client.py", line 385, in deploy_certificate
    self.installer.restart()
  File "/home/terra/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt_apache/configurator.py", line 1221, in restart
    self.config_test()
  File "/home/terra/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt_apache/configurator.py", line 1244, in config_test

MisconfigurationError: Error while running apache2ctl configtest.
Action 'configtest' failed.
The Apache error log may have more information.

apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 14 of /etc/apache2/sites-enabled/core.terragaming.co.uk-le-ssl.conf: Expected </VirtualHost> but saw </VirtualHost></IfModule>


2015-12-19 15:33:50,452:DEBUG:letsencrypt.error_handler:Calling registered functions
2015-12-19 15:33:50,452:CRITICAL:letsencrypt.client:Rolling back to previous server configuration...
2015-12-19 15:33:50,620:INFO:letsencrypt.reporter:Reporting to user: We were unable to install your certificate, however, we successfully restored your server to its prior configuration.
2015-12-19 15:33:50,623:DEBUG:letsencrypt.cli:Exiting abnormally:
Traceback (most recent call last):
  File "/home/terra/.local/share/letsencrypt/bin/letsencrypt", line 11, in <module>
    sys.exit(main())
  File "/home/terra/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/cli.py", line 1396, in main
    return args.func(args, config, plugins)
  File "/home/terra/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/cli.py", line 561, in run
    lineage.chain, lineage.fullchain)
  File "/home/terra/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt/client.py", line 385, in deploy_certificate
    self.installer.restart()
  File "/home/terra/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt_apache/configurator.py", line 1221, in restart
    self.config_test()
  File "/home/terra/.local/share/letsencrypt/local/lib/python2.7/site-packages/letsencrypt_apache/configurator.py", line 1244, in config_test
    raise errors.MisconfigurationError(str(err))

MisconfigurationError: Error while running apache2ctl configtest.
Action 'configtest' failed.
The Apache error log may have more information.

apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 14 of /etc/apache2/sites-enabled/core.terragaming.co.uk-le-ssl.conf: Expected </VirtualHost> but saw </VirtualHost></IfModule>

Error while running apache2ctl configtest.
Action 'configtest' failed.
The Apache error log may have more information.

apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 14 of /etc/apache2/sites-enabled/core.terragaming.co.uk-le-ssl.conf: Expected </VirtualHost> but saw </VirtualHost></IfModule>


IMPORTANT NOTES:
 - We were unable to install your certificate, however, we
   successfully restored your server to its prior configuration.

Bump? Still can’t get this working…

I can’t replicate it on my system, and not one I’ve come across ( the same for others I’d guess since you haven’t had lots of replies).

It might be worth flagging up as a bug on github - alternatively, try one of the many other clients

Thanks for the help, I will try completely re-making the server box from scratch later and see if that fixes my issues.

@groovyben008 Just seeing a common link of 2 others with the same issue … they had owncloud - are you using owncloud or anything that might be affecting the apache config in the same way ?

Nope, using a new digitalocean droplet with a self-installed LAMP stack.

This is happening to me as well, on a Debian VPS. I had it enabled for three domains with no issues, tried to add a fourth and began getting this.

Clearly, the script is at least temporarily writing out the le-ssl.conf. I’ve been trying for an hour to figure out if there is a way to get the script to output said file for me to review, but have had no luck at all.

Still haven’t fixed this issue, so no ideas…

Would you mind sharing your full apache config? Specifically, those files might be of interest:

  • /etc/apache2/apache2.conf
  • /etc/apache2/conf.d/*
  • /etc/apache2/sites-enabled/*
  • /etc/apache2/sites-available/*
  • Any other conf file anywhere (conf-enabled, mods-enabled, …) you might have modified or included from inside other conf files.

I have pretty much the same problem. Ubuntu 14.04, apache2. Cleaninstall (well, phpmyadmin is installed) and just one virtual host conf file

<VirtualHost *:80 >
	ServerName www.mydomain.io
	ServerAlias mydomain.io
	ServerAdmin info@mydomain.io
	DocumentRoot "/var/www/projects/mydomain/public"
	ErrorLog "/var/www/projects/mydomain/logs"
</VirtualHost>

Removing the ServerAlias doesn’t change anything. Not sure what to do here? :frowning:

apache2: Syntax error on line 219 of /etc/apache2/apache2.conf: Syntax error on line 12 of /etc/apache2/sites-enabled/mydomain-le-ssl.conf: Expected </VirtualHost> but saw </VirtualHost></IfModule>

I uploaded my apache.conf to pastebin but I don’t think there’s anything wrong with it?! I checked all the files that get included in lines 216 & 219 and everything looks good to me. I tried to output the mydomain-le-ssl.conf file but I had no luck with that so far.

All the files in /sites-enabled/ are symlinks to their respective files in /sites-available/, shouldn’t it be the same for the le-ssl.conf?

I had this problem as well. I solved it by pressing ENTER after and running the installation again.

I fixed this by putting a newline at the end of the conf file.

2 Likes

As said by @Konrad90, adding a newline to the end of each file fixed this issue for me.

newline fixed the issue. Thank You!

Fixed adding the new line as suggested. Here’s a one-liner:

for f in /etc/apache2/sites-available/*; do sed -i '$a\' "$f"; done

Credit: http://stackoverflow.com/questions/10082204/add-a-newline-only-if-it-doesnt-exist

1 Like

Correct!!
Just add an empty line at the end of your .conf file into the directory sites-available/

Thank You!
one newline at bottom fix this!