httpd: Syntax error on line 1295 of /etc/httpd/conf/httpd.conf: Expected </VirtualHost> but saw </Directory>

I installed PHP 7.3 and now Apache won't start. It won't start with this error:

httpd: Syntax error on line 1295 of /etc/httpd/conf/httpd.conf: Expected but saw

I've started going through the file, but there are a couple of hundred virtual servers on this server. I've already found some issue with mismatching opening and closing tags, but this is going to take some time. It seems to me that Virtualmin has completely bollocksed (am I allowed to say that?) this file.

I'm opening this ticket to start getting help and guidance, but my searches have only found on instance at , but a search inside this system didn't show any tickets opened as a result of that. I'm also not using Coudmin.

I just followed the instructions at , and now I have this problem when trying to get Virtualmin to recognise the new installation.


Virtualmin version: 
Webmin version: 


Is there a way to automatically rebuild /etc/httpd/conf/httpd.conf?

I have at least 14 anomalies where VirtualHost contains are not closed. Just off the top of my head from memory (because it's been so long since I configured this by hand), I don't believe these can be nested.

Yeah, that last question ("Can Virtualmin automatically rebuild /etc/httpd/conf/httpd.conf?") is really the key here. Anyone have any idea?

Just to be clear, I did not manually edit this config file. Virtualmin seems to have broken it by trying to add PHP 7.3 to the VirtualHost configurations.

There is nothing at Webmin -> Servers -> Apache Webserver that would suggest that Virtualmin can automatically rebuild the borked file.

Would there be an automated back-up of this particular file somewhere? I may need to retrieve one from a deeper and more complicated location, but if I knew there was one created by Virtualmin somewhere, that would sure help.

Eric, Jamie,

Is there documentation on what lines Virtualmin adds (and possibly removes) to (and from) the httpd.conf file when trying to reconfigure it after adding PHP 7.3?


I restored an old copy of the file, and Apache is again running. I have not used Virtualmin to "Re-Check Configuration", as I need to analyse the differences between the working file and the corrupted one before I proceed.

However, answers to the above questions would be helpful in that regard. Thanks.


Would it be possible to attach the httpd.conf file after it was corrupted and after you fixed it to this bug report? I'd like to see the diff, and from that figure out what Virtualmin did to break it.


Yes, I suppose so. I did a diff to see the differences between the old and new files and, while I noticed one pattern, it was just too much for me to deal with at the time. I have yet to find time to get the newer version of PHP working on the server.

So are you suggesting that there is no way to have Virtualmin rebuild the httpd.conf file?


Oh, and in my panic yesterday I didn't notice that this system had stripped out the stuff between the angular brackets. This was the error:

httpd: Syntax error on line 1295 of /etc/httpd/conf/httpd.conf: Expected </VirtualHost> but saw </Directory>

But it's in the subject anyway.

Virtualmin doesn't have a way to rebuild the whole httpd.conf , as some settings for each virtual server are stored in the config file. We could offer a feature to re-generate a domain's virtualhost block, but that wouldn't work if the end of the block itself is corrupted as in your case.

I see. I don't know that "the end of the block itself is corrupted". It's not as if the end of the file is truncated in the middle of a directive or that it ends in a mass of control characters. It's hard to know what actually happened if, as I say, there seems to me 14 instances where VirtualHost directives are closed or opened where they shouldn't be, which is pretty much what the error message alludes to.

So are you say you "could offer a feature to re-generate a domain's virtualhost block" in a future version, or is there some way I can attempt it now?

You could disable the website for the domain, then enable it again. However, this will delete any redirects or per-directory PHP versions you have setup.

That's not going to work, as I'd have to do it manually a couple of hundred times and, as you say, I'd then have to go back and fix everything that was deleted.

What does Virtualmin do when I "Re-Check Configuration"? After I had installed PHP 7.3, I twice tried to do that; the page started to load, and then sat there for ages (several minutes anyway) with the Virtualmin progress bar going back and forth. Eventually that even stopped. Same happened the next time I tried. I then rebooted the server and that's when Apache wouldn't start.

Did the "Re-Check Configuration" do the damage?

I'm wondering if perhaps my interrupting the "Re-Check Configuration" twice caused the problem.

Not unless you ran it twice at the same time from different SSH sessions?

No, as I described above, I only ran it in the web-based control panel, but the output stopped there leading me to try again.

What is the command to do it via SSH, and will there be progress output so that I don't interrupt the process?

Via SSH, you can run virtualmin check-config

That doc is no longer accurate - the check-config command does update some configuration files if needed (ie. if Apache is configured to use a PHP version that's not installed).

I had to wait for the weekend to try and make progress on this, in case Apache went down again.

As suggested, I ran virtualmin check-config at the command line. It took about 20 minutes to complete (while it told me what it was doing), and httpd.conf grew by about 21 kB. Afterwards I ran apachectl configtest and got Syntax OK. Inside Virtualmin (on the web, as opposed to on the command line) the newer version of PHP (7.3) was showing, as I believe it had previously. So I restarted Apache. Everything worked as expected.

I would say that the lack of output from System Settings -> Re-Check Configuration the first time around -- described in message 15 -- led to me interrupting the loading of that page and trying to reload it a second time, and perhaps that's what caused httpd.conf to be borked. So I realise I can be a little impatient, but usually Virtualmin does a decent job of providing output to let me know that a process in underway. In this case it didn't, which led me to take actions which likely caused the problem.

Jamie, in message 9 you asked for copies of the corrupted httpd.conf file and what it looked like after I fixed it. I didn't fix it -- virtualmin check-config did -- and a quick scan of the diff shows that these lines were added, for each virtual server:

AddHandler fcgid-script .php7.3
FCGIWrapper /home/nineroot/fcgi-bin/php7.3.fcgi .php7.3
RemoveHandler .php7.3

If you want the full files I can provide them privately if you wish.

So this issue has been solved. Now I'll carry on with what I started last week and install PHP 7.4 and probably 8.0.

I forgot to obfuscate a user name. Obviously the user names changed between virtual servers.

I should add that in the output of virtualmin check-config was the following:

Updating all Webmin users with new settings..
Use of uninitialized value $salt in pattern match (m//) at /usr/libexec/webmin/acl/ line 1662.
Use of uninitialized value $salt in pattern match (m//) at /usr/libexec/webmin/acl/ line 1662.
Use of uninitialized value $salt in numeric eq (==) at /usr/libexec/webmin/acl/ line 1662.
.. done

Should I be concerned about this?

Installing PHP 7.4 and 8.0 also went well, with using virtualmin check-config on the command line in between. I didn't try to use System Settings -> Re-Check Configuration in the web-based control panel again.

No, that warning message about $salt is totally harmless.