Apache Webserver won't come on

Please Help Joe or any staff if you are available

Webmin and Virtualmin using system as below

SYSTEM INFORMATION
OS type and version CentOS Linux 7.9.2009 EOL imminent
Webmin version 2.111
Usermin version 2.010
Virtualmin version 7.10.0
Theme version 21.10

Apache Webserver does not come on
and check says
[root@vmi431722 ~]# sudo apachectl configtest
AH00526: Syntax error on line 2622 of /etc/httpd/conf/httpd.conf:
cannot occur within section

Now what do I do? where do I go to find this line 2622? I’m not sure of what steps to take now
This happened to me sometime ago and I did get it going - but have forgotton
Please Help Joe or any staff if you are available

My version doesn’t have that file. But, you should be able to open that file in the Webmin portion. I’m not sure if # lines are counted though.

Not sure if this offers clarity since my file is OK.
apachectl configtest

Thanks for your quick reply in the meantime I got the Apache Webserver config file from the menu of Webmin>Servers>Apache Webserver then saw the Config File in there

Located the line 2622 - it refers to a website I have on virtualmin called babylyk but the website does not come up and so whilst I was trying to get that going the Apache Server shut off and won’t come on again
The line 2622 reads as below

<VirtualHost *:80>

wonder what i should edit it to?

My configs list an address there. I think the * is a wildcard for all addresses so I’m not sure that’s the problem. Like I said above, sometimes these things ignore the # lines so they aren’t included in the actual ‘used’ line count as such. Does your error log give a better message?

My system breaks the logs into nice chunks for each site and different components so it doesn’t have that huge file to parse.

According to the docs…
configtest
Run a configuration file syntax test. It parses the configuration files and either reports Syntax Ok or detailed information about the particular syntax error. This is equivalent to apachectl -t.

that’s what I did to start with and here is what I got…
[root@vmi431722 ~]# apachectl configtest
AH00526: Syntax error on line 2622 of /etc/httpd/conf/httpd.conf:
cannot occur within section

Getting beyond the point I feel comfortable giving much advice. Is there anything specific that happened prior to this?

The only thing I can think of is dump the file without the comments and see if there is another line 2622 that pops up.

I’m hoping one of the Staff can help - I just don’t know how to get their attaention … Just keep waiting until they see this?

Do you have this? Not sure what you see on your OS. It might give some other clue.

Here’s what my one looks like

OK. You have httpd/logs/error_log
Check that file.
Also found this. It shows only the actual lines used by Apache without the # cluttering it up. You can dump this to a file and, I’m guessing, find the correct line that way.
apachectl -S1

[Sun May 26 03:14:07.164400 2024] [lbmethod_heartbeat:notice] [pid 1198] AH02282: No slotmem from mod_heartmonitor
[Sun May 26 03:14:07.247388 2024] [ssl:warn] [pid 1198] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sun May 26 03:14:07.476941 2024] [mpm_prefork:notice] [pid 1198] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/8.2.19RC1 configured – resuming normal operations
[Sun May 26 03:14:07.477029 2024] [core:notice] [pid 1198] AH00094: Command line: ‘/usr/sbin/httpd -D FOREGROUND’
[Sun May 26 16:01:36.331008 2024] [mpm_prefork:notice] [pid 1198] AH00171: Graceful restart requested, doing restart
[Sun May 26 16:01:40.943496 2024] [lbmethod_heartbeat:notice] [pid 1198] AH02282: No slotmem from mod_heartmonitor
[Sun May 26 16:01:41.023118 2024] [ssl:warn] [pid 1198] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sun May 26 16:01:41.133322 2024] [mpm_prefork:notice] [pid 1198] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/8.2.19RC1 configured – resuming normal operations
[Sun May 26 16:01:41.133372 2024] [core:notice] [pid 1198] AH00094: Command line: ‘/usr/sbin/httpd -D FOREGROUND’
[Sun May 26 16:02:37.966346 2024] [mpm_prefork:notice] [pid 1198] AH00171: Graceful restart requested, doing restart
[Sun May 26 16:02:41.335145 2024] [lbmethod_heartbeat:notice] [pid 1198] AH02282: No slotmem from mod_heartmonitor
[Sun May 26 16:02:41.383993 2024] [ssl:warn] [pid 1198] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sun May 26 16:02:41.682130 2024] [mpm_prefork:notice] [pid 1198] AH00163: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips mod_fcgid/2.3.9 PHP/8.2.19RC1 configured – resuming normal operations
[Sun May 26 16:02:41.682259 2024] [core:notice] [pid 1198] AH00094: Command line: ‘/usr/sbin/httpd -D FOREGROUND’
[Mon May 27 21:30:21.681290 2024] [mpm_prefork:notice] [pid 1198] AH00170: caught SIGWINCH, shutting down gracefully

OK. I’m a networking guy. :wink: One last thing that looks good for finding the actual line.
As described in the Apache HTTP Server Documentation

If the config define -DDUMP_CONFIG is set, mod_info will dump the pre-parsed configuration to stdout during server startup.

httpd -DDUMP_CONFIG -k start
DUMP_CONFIG requires mod_infoenabled: a2enmod info!

It describes how to remove line numbers so I’m assuming this version of the command won’t.
second answer down.

Thanks for all your help … but I’m getting further and further away and so have reverted it all back to waht it was originally

you see it said error on line 2622 so i changed that and it still wouldn’t start so i did the check test again and it said another line error so i corrected that and then the same thing ahhpened again…
It was all working perfectly well before … this just happened as one of the websites would not launch it said cannot connect and i tried to change a line on the server … as everything else pointing domain etc is all perfect and working…
I’ve reverted it all back to as it was before- the apache server is not starting
and the check says again as it did before error on line 2622

I had this before and there is a staff member called Joe who helped me correct it very quickly - he knew exactly what lines to change etc -
I think I’ll wait for the satff to reply and help me on this…

Thanks again for all your help and effort to try get me going… :smile:

You need to show us what you’ve got on that line (and the others with syntax errors). I can’t possibly guess what’s wrong without more information.

And, if it’s the same problem you’ve had before, maybe the solution is the same one I suggested before?

Hi Joe the line is as below

It’s not the same problem - last time it was the Updates that did this… this time It seems I’m at fault??
Is there a way I can send you the whole config file?
As I tried removing the line 2622 and checked and it said another line had another error i changed that then it went on and on to new lines
whereas it was all working fine before
it may help if I sent you the whole file - please tell me how

That seems very unlikely.

You have a bogus extra <VirtualHost> entry. That doesn’t make sense inside of another VirtualHost section. You should remove that line.

I did that and still the Apache Server won’t start so I did a check test and now it says
[root@vmi431722 ~]# sudo apachectl configtest
httpd: Syntax error on line 2707 of /etc/httpd/conf/httpd.conf: without matching section

line 2707 is as below

looks like the same problem here as well so I removed the line 2707
and it still won’t start si I did a check again and here is what it says:
[root@vmi431722 ~]# sudo apachectl configtest
AH00526: Syntax error on line 2645 of /etc/httpd/conf/httpd.conf:
SSLCertificateFile: file ‘/etc/ssl/certs/yourcert.pem’ does not exist or is empty
Here is the line 2645 and all below that

not sure what to do now - Please help Joe