Apache won't restart because of a disabled and then deleted domain

Weird bug I ran into. Just to be clear, this is NOT a support request, but since I stumbled upon it, I think it's helpful to report it.

So: because I have a problem ( https://www.virtualmin.com/node/64983 ) I thought I would try to restart Apache and see it it helps.

Buuuut, here comes a test website I disabled in virtualmin long ago, let's call it the-problem-website.com

root@my-reverse.tld:~# service apache2 status
Apache2 is running (pid 6187).
root@my-reverse.tld:~# service apache2 restart
[Mon Mar 11 09:34:26 2019] [notice] Digest: generating secret for digest authentication
Syntax error on line 72 of /etc/apache2/sites-enabled/the-problem-website.com.conf:
SSLCertificateFile: file '/home/the-problem-website/ssl.cert' does not exist or is empty
Action 'configtest' failed.
The Apache error log may have more information.
failed!
root@my-reverse.tld:~# service apache2 status
Apache2 is running (pid 6187).
root@my-reverse.tld:~#

I think I remember I ran tests on that website, and among them was the deletion of the ssl.something files at the root of the hosting account for that website.

So at this point, I have to re-activate the website, re-install a Let's Encrypt certificate, and only then am I amble to restart Apache, apparently.

This is so weird I dare call this a bug and report it :)

**

UPDATE: just before I would click to submit my ticket, I thought "oh, to hell with it" and deleted entirely the virtual domain in virtualmin. Successfully deleted. The /home/the-problem-website/ directory has also disappeared.

Apache still won't restart,

root@my-reverse.tld:~# service apache2 status
Apache2 is running (pid 6187).
root@my-reverse.tld:~# service apache2 restart
[Mon Mar 11 09:43:01 2019] [notice] Digest: generating secret for digest authentication
Warning: DocumentRoot [/home/the-problem-website/public_html] does not exist
Syntax error on line 19 of /etc/apache2/sites-enabled/the-problem-website.com.conf:
Wrapper /home/the-problem-website/fcgi-bin/php5.fcgi cannot be accessed: (2)No such file or directory
Action 'configtest' failed.
The Apache error log may have more information.
failed!
root@my-reverse.tld:~#

Sure enough, in /etc/apache2/sites-enabled/ there was the .conf file for that first disabled, and then deleted virtual domain.

*

So, here's for my bug report, apparently Virtualmin doesn't 100% clean after itself in certain situations. (In case details matter: I have Virtualmin GPL, latest stable, on a Debian7.)

May I ask just one thing, in exchange for a hopefully helpful bug report? May I safely delete the-problem-website.conf from apache2/sites-enabled? I'm afraid I would have problems if my server must restart as things are now, but don't know if just deleting the website's .conf file is enough.

Status: 
Active

Comments

Howdy -- thanks, that does indeed sound like a bug!

It sounds like it's working now that you re-enabled the site.

With that in mind, you should then be able to delete the site entirely, as it sounds like that's the goal. I suspect deleting it outright will properly remove the .conf file.

That said, if it doesn't, it's no problem to manually remove the .conf file from the /etc/apache2/sites-enabled directory.

Jamie will comment more on the issue you're seeing though.

Thanks for the confirmation I can safely unlink the site's .conf file from sites-enabled, I wouldn't have wanted to cause chaos.

Quotation: "It sounds like it's working now that you re-enabled the site." No.

Just to clarify, in case you want to see if the bug can be reproduced for confirmation.

(1) At the very beginning, when the virtual domain wasn't disabled yet, because of letsencrypt issues (probably caused because at the beginning I tried to setup letsencrypt with the commandline utility and not with virtualmin, and virtualmin doesn't want to setup letsencrypt then, a problem I later circumvented for other virtual domains by removing /etc/letsencrypt/ and then running again the virtualmin procedure ), I tested to see if it did something to delete the ssl.something files present at the site's ~ directory. That didn't fix the issues, so I disabled the website anyway (it was abandoned, so why not).
(2) Fast forward to yesterday, I want to restart Apache but I get an error message because of that disabled virtual domain, the server refuses to allow me stop and restart apache2 because it notices it won't find ssl.cert for the disabled website and it will cause a problem.
(3) I give up and ask virtualmin to delete the disabled virtual domain, virtualmin complies gracefully, zero problem.
(4) I ask the system to restart apache2, once again, refusal because of a missing file ( fcgi-bin/php5.fcgi ) mentioned in that website's .conf file in sites-enabled

This is the actual bug here, the presence of that virtual domain's .conf file in sites-enabled even though virtualmin successfully deleted the already disabled domain (it's not listed anymore in the virtual domains in virtualmin). I realize, the .conf file should have been unlinked from sites-enabled (only stay in sites-available) ever since I disabled the domain, by the way, no?

(sorry for the looong answer, I'm way out of my league so I'm not sure which info is helpful or not)

That's a surprising failure case, because normally sites-enabled just contains symlinks to files in sites-available. Was the file in sites-enabled an actual file in your case?

I should have chosen my words more carefully: in sites-enabled, this is indeed just a symlink of the .conf in sites-enabled.

No idea why it wasn't removed from there when I deleted the domain (or, I now wonder, if the bug didn't start even before that: should the symlink have stayed present in sites-installed after I had disabled the virtual domain?), which is the actual bug that had to be reported.

Don't know if this is the same but recently after deleting a domain that had ssl cert, apache complained about having ssl configured for non existing domain. I had to delete the ssl lines in apache config before apache would restart. Unsure exactly what conf file as I just did it and moved on, but had to remove letsencrypt cert lines for that domain. Then apache restarted just fine.

Ok, so the trigger was that both the files in sites-enabled and sites-available still existed even after the domain was deleted, but were of course invalid because they referred to missing directories?

When you deleted the domain, was any error message reported?

Yep, I've had this issue as well as "logrotate errors". I've manually removed/added many a domain to the log rotate config files. Hey, all in a day's work, right? : )

"When you deleted the domain, was any error message reported?"

I don't think there was anything particular reported, just the system messages related to a done job.

Honestly I only watched it from the corner of my eye so I cannot tell I'm 100% sure, but no catchy words such as "error", "fail", "report" or the like caught my eye, this behaved like any operation in virtualmin, smoothly.