If you are trying to install apache2 webserver as we mentioned in our another post “How to install Apache webserver on Ubuntu ?” there are chances that you may see an error like “systemd[1]: Failed to start The Apache HTTP Server.” in a red color on command line as below,
Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "start" failed.
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: failed (Result: exit-code) since Mon 2020-05-18 23:42:39 IST; 6ms ago
Process: 5424 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
May 18 23:42:39 devlab apachectl[5424]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
May 18 23:42:39 devlab apachectl[5424]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
May 18 23:42:39 devlab apachectl[5424]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
May 18 23:42:39 devlab apachectl[5424]: no listening sockets available, shutting down
May 18 23:42:39 devlab apachectl[5424]: AH00015: Unable to open logs
May 18 23:42:39 devlab apachectl[5424]: Action 'start' failed.
May 18 23:42:39 devlab apachectl[5424]: The Apache error log may have more information.
May 18 23:42:39 devlab systemd[1]: apache2.service: Control process exited, code=exited status=1
May 18 23:42:39 devlab systemd[1]: apache2.service: Failed with result 'exit-code'.
May 18 23:42:39 devlab systemd[1]: Failed to start The Apache HTTP Server.
Solution
Its possible that you may already have some other webserver running on your website which is using port 80, hence it was showing an error as “Address already in use: : make_sock: could not bind to address” so we have to identify which application is using this port 80 and stop this application so as we can install apache2.
Check which app is using port 80, you can use below command and Close this program and kill using command line. [ You can also refer to our post “Identify which application / process is using which port or keeping it busy on android / Linux” ]
$ sudo netstat -nap | grep 80
In our Desktop, we had “lighthttpd” installed and running which was causing this problem, so we used below command to identify it as,
$ ps -ax | grep httpd
6165 ? Ss 0:00 /usr/sbin/lighttpd -D -f /etc/lighttpd/lighttpd.conf
and then stopped this webserver as,
$ sudo /etc/init.d/lighttpd stop
[ ok ] Stopping lighttpd (via systemctl): lighttpd.service.