Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

I can't restart the apace2 if I open the SSL port 443 in file of `/etc/apache2/ports.conf ` in ubuntu 18.04LTS

Writer Mia Lopez

I get a problem in 18.04.I want to configure the SSL for my website, so I edit the profile in etc/apache2/ports.conf and add the line like Listen 443, but when I do service apache2 restart the apahce service can't be restarted but it just work fine in 16.04 like that.Then I delete the line Listen 443 and the Apache service works again..

It says:Job for apache2.service failed because the control process exited with error code.See "systemctl status apache2.service" and "journalctl -xe" for details.

journalctl -xe:

 ubuntu apachectl[2867]: AH00526: Syntax error on line 8 of /etc/apache2/ports.conf: ubuntu apachectl[2867]: Cannot define multiple Listeners on the same IP:port ubuntu apachectl[2867]: Action 'start' failed. ubuntu apachectl[2867]: The Apache error log may have more information. ubuntu systemd[1]: apache2.service: Control process exited, code=exited status=1 ubuntu systemd[1]: apache2.service: Failed with result 'exit-code'. ubuntu systemd[1]: Failed to start The Apache HTTP Server.

The line 8 is just what I add.. It dose work in 16.04 if I do the same thing, I want to know is anything changed in 18.04?

1 Answer

I've conducted a small investigation - yes there is a different behaviour between Apache2's versions that come with Ubuntu 16.04 and Ubuntu 18.04.

  • 16.04 comes with Apache/2.4.18 and there is no matter how many times you will repeat identical Listen directives - I've tested that on a virtual machine.

  • 18.04 comes with Apache/2.4.29 and in the current Apache2.4 documentation is written:

    Error condition

    Multiple Listen directives for the same ip address and port will result in an Address already in use error message.

In your case the directive Listen 443 appears twice within the Apache's configuration, so according to these new rules it is normal to receive the above error.

By default, within ports.conf, the directive Listen 443 is enclosed with <IfModule> tags, as follow:

Listen 80
<IfModule ssl_module> Listen 443
</IfModule>
<IfModule mod_gnutls.c> Listen 443
</IfModule>

That means it will be active only when mod_ssl (or mod_gnutls) is enabled. So, if you have enabled mod_ssl, you do not need to put any additional Listen 443.


You can investigate how many times and where the directive Listen 443 appears in your configuration by the command:

grep -rni 'listen 443' /etc/apache2/

You can check which Apache's modules are enabled by the command(s):

sudo apachectl -M
sudo apachectl -M | grep 'ssl\|tls'

You can check whether any service listen to port 443 and which is it by the commands:

sudo lsof -i -n -P | grep ':443'
sudo netstat -peanut | grep ':443'

Further reading: How to secure Apache with Let's Encrypt.

4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy