Fixing and removing corrupted Apache configs in Plesk

Today I ran into an interesting problem with Plesk. It had gotten it’s Apache configuration so messed up that when you ran httpdmng reconfigure for any domain, it would throw errors about not being able to find include files. For example:

apache2: Syntax error on line 227 of /etc/apache2/apache2.conf: Syntax error on line 7 of /etc/apache2/conf.d/zz010_psa_httpd.conf: Syntax error on line 15 of /opt/psa/admin/conf/generated/14099869670.15839100_horde.include: Syntax error on line 56 of /opt/psa/admin/conf/webmail_horde_bootstrap.conf: Could not open configuration file /opt/psa/admin/conf/generated/14099802590.70236400_domain_com_webmail.include: No such file or directory

The fix for this involves some MySQL work. Go into the “psa” database in MySQL. You’ll see a “Configuration” table there. Take note of the numbered sequence in the config file name in amongst the errors thrown when running httpdmng. It will look like 14099859010.42476800. Now look for rows whose “version” column matches the number sequences and delete them.
Go back into /opt/psa/admin/conf/ and remove all references to the config files in vhosts_bootstrap.conf, webmail_*_bootstrap.conf, and in the generated/ directory.
After that you should be able to run /opt/psa/admin/sbin/httpdmng –reconfigure-all without problems.