Apache breaking after installing php in attempt to get occ command working

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 32.0.3
  • Operating system and version (e.g., Ubuntu 24.04):
    • Linux LMDE 7 Gigi
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.65
  • Reverse proxy and version _(e.g. nginx 1.27.2)
    • Nginx 2.13.5
  • PHP version (e.g, 8.3):
    • 8.4.16
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • After installing php
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • AIO
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • Yes, for domains only

Summary of the issue you are facing:

Today I was trying to run the occ command script by typing “sudo -E -u www-data php occ” to test, and I got “php: command not found” so I figured I’d install php. After installing it, it reported back with errors on restarting apache2 saying “(98)Address already in use: AH00072: make_sock: could not bind to address [::]:80” and “(98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80”.

I already had apache2 installed beforehand so I figured something in the php install mucked it up. Before attempting to fix it I checked if my nextcloud instance was still running and it was, so this wasn’t a critical error but a cumbersome one. I ran “sudo apt purge libapache2-mod-php*” which seemed to be the offending package, and then “sudo a2dismod mpm_prefork” and “sudo a2enmod mpm_event” in an attempt to get apache2 back to the state it was before, but neither worked.

I’d like to get it in a working state again, I’m not entirely sure how my nextcloud instance still works fine on my apache port despite the service itself not running (double service maybe? idk). The a2enmod and a2dismod commands were at the advice of ChatGPT (I know, but I sometimes use it to help me in a pinch), and I know I’m gonna start scrambling and panicking if I keep trying to fix this further, so I thought I’d just stop there and make a post.

and I still can’t use occ (either I’m using the wrong command or it doesn’t work).

Steps to replicate it:

  1. “sudo apt install php” with apache installed already

  2. apache reports back that it failed to start, says there are services listening on port 80 and 0.0.0.0:80 already. I do have some other services listening in on port 80 such as nginx and amp, but everything worked fine before installing php.

  3. Run “sudo apt purge libapache2-mod-php*”, “sudo a2dismod mpm_prefork” and “sudo a2enmod mpm_event” in an attempt to get it back in a happy state, doesn’t work.

Log entries

apache2 systemctl status

× apache2.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: failed (Result: exit-code) since Mon 2025-12-22 02:53:35 EST; 9s ago
 Invocation: 41d451bb3ec7429c8de0cc99f16ea1af
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 2737636 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
   Mem peak: 3.5M
        CPU: 20ms

Dec 22 02:53:35 thinkpad-e490 systemd[1]: Starting apache2.service - The Apache HTTP Server...
Dec 22 02:53:35 thinkpad-e490 apachectl[2737638]: AH00558: apache2: Could not reliably determine the server's fully qualifi>
Dec 22 02:53:35 thinkpad-e490 apachectl[2737638]: (98)Address already in use: AH00072: make_sock: could not bind to address>
Dec 22 02:53:35 thinkpad-e490 apachectl[2737638]: (98)Address already in use: AH00072: make_sock: could not bind to address>
Dec 22 02:53:35 thinkpad-e490 apachectl[2737638]: no listening sockets available, shutting down
Dec 22 02:53:35 thinkpad-e490 apachectl[2737638]: AH00015: Unable to open logs
Dec 22 02:53:35 thinkpad-e490 systemd[1]: apache2.service: Control process exited, code=exited, status=1/FAILURE
Dec 22 02:53:35 thinkpad-e490 systemd[1]: apache2.service: Failed with result 'exit-code'.
Dec 22 02:53:35 thinkpad-e490 systemd[1]: Failed to start apache2.service - The Apache HTTP Server.

A small netstat -tulpen should show you the processes bound to specific ports.

Or if it is a config problem in apache:
apache2ctl configtest

Hi @SwellEquation36 see GitHub - nextcloud/all-in-one: 📦 The official Nextcloud installation method. Provides easy deployment and maintenance with most features included in this one Nextcloud instance.

1 Like

I have nginx master running on port 80, and visiting the port from my local IP brings up the page attached.

I also have it running on port 81 which is the one I’m using. How would I stop it from using port 80? I don’t seem to have a /etc/nginx folder

Edit: After some testing I realized that I don’t even need php or apache2 installed as everything is handled through docker, so I disabled apache2 and purged php.

I also have nginx in a docker container on host mode which I need for a service I’m running, and it discards mapped ports, so removing port 80 from the compose file doesn’t stop it from using it. Not an issue anymore though, as apache2 is donezo anyway.

I feel silly now, thanks szaimen for posting the correct documentation on how to use occ.

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.