I have strange behaviour on my opensuse 15.4 apache2 server. The service doesn’t start and gives back:
Sep 25 10:46:14 shuttloj start_apache2[29548]: AH00526: Syntax error on line 16 of /etc/apache2/listen.conf:
Sep 25 10:46:14 shuttloj start_apache2[29548]: Cannot define multiple Listeners on the same IP:port
Sounds simple enough, but isn’t because the configs show only 1 connection
yes, true, but that is the only server, and I can’t go without that, i need to state that in virtualhosts.conf, don’t I? (I don’t have a default server, i want to install more than one virtual servers, namebased, but I have deleted them in virtualhosts.conf temporarily, to simplify it and find the mistake)
Sorry i’m not that expert at Apache, but i believe it has something to do with your listen configuration and your virtualhost config. There are some hints in the apache documentation which may help: https://httpd.apache.org/docs/2.4/en/bind.html
How This Works With Virtual Hosts
The Listen directive does not implement Virtual Hosts - it only tells the main server what addresses and ports to listen on. If no <VirtualHost>](core - Apache HTTP Server Version 2.4) directives are used, the server will behave in the same way for all accepted requests. However, <VirtualHost>](core - Apache HTTP Server Version 2.4) can be used to specify a different behavior for one or more of the addresses or ports. To implement a VirtualHost, the server must first be told to listen to the address and port to be used. Then a <VirtualHost>](core - Apache HTTP Server Version 2.4) section should be created for the specified address and port to set the behavior of this virtual host. Note that if the <VirtualHost>](core - Apache HTTP Server Version 2.4) is set for an address and port that the server is not listening to, it cannot be accessed.
/etc/apache2/listen.conf:# Listen: Allows you to bind Apache to specific IP addresses and/or
/etc/apache2/listen.conf:# https://httpd.apache.org/docs/2.4/mod/mpm_common.html#listen
/etc/apache2/listen.conf:# Change this to Listen on specific IP addresses as shown below to
/etc/apache2/listen.conf:# When we also provide SSL we have to listen to the
/etc/apache2/listen.conf:# Listen directives: “Listen ::]:443” and “Listen 0.0.0.0:443”
/etc/apache2/listen.conf:Listen 192.168.2.38:80
/etc/apache2/listen.conf:# Listen 443
/etc/apache2/httpd.conf:# |-- listen.conf . . . . . . . . . . . . . IP adresses / ports to listen on
/etc/apache2/httpd.conf:# |-- listen.conf
/etc/apache2/httpd.conf:# IP addresses / ports to listen on
/etc/apache2/httpd.conf:Include /etc/apache2/listen.conf
Apache2 is started now. Great!
(not my fault, though, I don’t know why the config is included twice by default, I haven’t done that myself.
So, for anyone with the same problem. When you do :
systemctl start httpd
or
apachectl -S
and this comes:
AH00526: Syntax error on line 16 of /etc/apache2/listen.conf:Cannot define multiple Listeners on the same IP:port
… but /etc/apache2/listen.conf and httpd.conf have together only one “Listen” Directive, and you are wondering where the “multiple listeners” come from,
then look in /etc/sysconfig/apache2 and see if httpd.conf is loaded from there as well, because it will be loaded anyway, and thus fail on double loading the Listen directive