0

My apache2 had the following error:

root@Aspire3:/etc/apache2# systemctl status apache2
● 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 Thu 2020-10-08 20:42:23 -03; 4min 48s ago
  Process: 24443 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)

out 08 20:42:23 Aspire3 apachectl[24443]: 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 out 08 20:42:23 Aspire3 apachectl[24443]: (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80 out 08 20:42:23 Aspire3 apachectl[24443]: (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80 out 08 20:42:23 Aspire3 apachectl[24443]: no listening sockets available, shutting down out 08 20:42:23 Aspire3 apachectl[24443]: AH00015: Unable to open logs out 08 20:42:23 Aspire3 apachectl[24443]: Action 'start' failed. out 08 20:42:23 Aspire3 apachectl[24443]: The Apache error log may have more information. out 08 20:42:23 Aspire3 systemd[1]: apache2.service: Control process exited, code=exited status=1 out 08 20:42:23 Aspire3 systemd[1]: apache2.service: Failed with result 'exit-code'. out 08 20:42:23 Aspire3 systemd[1]: Failed to start The Apache HTTP Server.

Then I found this response and it worked! But whenever I restart my computer, Apache returns to this error and I have to run these commands again. Does anyone know how to solve? I use Ububtu 18.04

Carolina
  • 171
  • 2
    The response you linked basically just says "find the process and kill it". If you want a persistent solution, you will either need to prevent the corresponding service from starting - either by disabling it or by masking it - or configure the two services to use non-conflicting ports. See for example Can I run nginx and apache at the same time? – steeldriver Oct 14 '20 at 14:04

2 Answers2

0

Could be an issue with your firewall.

Try sudo ufw allow 'Apache Full'; sudo systemctl restart apache2 and see if that helps.

If not, please provide a little more detail as to the commands you need to run in order to get the server working again. Worst case scenario, you can make a bash script with the commands and then make a cron job to run them at startup (not the best solution but it works).

Vasilisa
  • 579
  • 2
  • 15
0

I have this problem right now. I figured out what the problem is, I installed NextCloud and this is spawning 4 different httpd processes listening on port 80. How I figured this out is this, first run:

sudo ss -6 -tlnp | grep 80

and it output this:

LISTEN    0         511                      *:80                     *:*        users:(("httpd",pid=3736,fd=4),("httpd",pid=3735,fd=4),("httpd",pid=3734,fd=4),("httpd",pid=3732,fd=4))

I tried killing all these processes, but it instantly spawned new ones:

LISTEN    0         511                      *:80                     *:*        users:(("httpd",pid=220235,fd=4),("httpd",pid=220234,fd=4),("httpd",pid=220233,fd=4),("httpd",pid=220232,fd=4))

so to find out what is spawning these processes, I ran this:

ps -feww | grep httpd

and the output:

root      219647       1  0 16:00 ?        00:00:00 /bin/sh /snap/nextcloud/28403/bin/run-httpd -k start -DFOREGROUND
root      220190  219647  0 16:00 ?        00:00:00 /bin/sh /snap/nextcloud/28403/bin/httpd-wrapper -k start -DFOREGROUND
root      220232  220190  0 16:00 ?        00:00:00 httpd -d /snap/nextcloud/28403 -k start -DFOREGROUND
root      220233  220232  0 16:00 ?        00:00:00 httpd -d /snap/nextcloud/28403 -k start -DFOREGROUND
root      220234  220232  0 16:00 ?        00:00:00 httpd -d /snap/nextcloud/28403 -k start -DFOREGROUND
root      220235  220232  0 16:00 ?        00:00:00 httpd -d /snap/nextcloud/28403 -k start -DFOREGROUND
sugarca+  230559   19376  0 16:02 pts/0    00:00:00 grep --color=auto httpd

So to fix the problem I uninstalled nextcloud.