apache2.service: Failed to run 'start' task: No such file or directory

I can't restart my apache server on debian 9.

I tried reinstall :

sudo apt-get autoremove --purge apache2 && sudo apt-get install apache2

but no change...

Job for apache2.service failed because of unavailable resources or another system error.
See "systemctl status apache2.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apache2, action "restart" failed.

systemctl status apache2.service

● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
   Active: failed (Result: resources)

journalctl -xeu apache2.service (I set loglevel to debug mod)

Sep 05 11:45:44 systemd[1]: apache2.service: Failed with result 'resources'.
Sep 05 11:50:26 systemd[1]: apache2.service: Changed dead -> failed
Sep 05 11:50:27 systemd[1]: apache2.service: Trying to enqueue job apache2.service/stop/replace
Sep 05 11:50:27 systemd[1]: apache2.service: Installed new job apache2.service/stop as 1415
Sep 05 11:50:27 systemd[1]: apache2.service: Enqueued job apache2.service/stop as 1415
Sep 05 11:50:27 systemd[1]: apache2.service: Job apache2.service/stop finished, result=done
Sep 05 11:50:27 systemd[1]: apache2.service: Changed dead -> failed
Sep 05 11:50:30 systemd[1]: apache2.service: Failed to run 'start' task: No such file or directory
Sep 05 11:50:30 systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- Unit apache2.service has failed.
-- 
-- The result is failed.
Sep 05 11:50:30 systemd[1]: apache2.service: Failed with result 'resources'.

what's wrong?


If you use the default Apache configuration, it tries to listen on port 80 which is already in use by nginx. Change your Apache configuration to listen on port 88 instead.

listen 88

you may want to check if there is an environment file. in Debian based systems this would be found in /etc/default/$file (not sure what actual file name is) on CentOS/RHEL based systems it would be found in /etc/sysconfig/httpd...

I'm *adding this answer since I had this issue and a format is not an option... So for whoever may stumble across this I had to figure it out myself. The giveaway was the startup script.

cat /etc/systemd/system/httpd.service | grep -i environment  

EnvironmentFile=/etc/sysconfig/httpd