1

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?

Matrix
  • 145
  • 2
  • 10
  • Can you find any useful logging in _/var/log/messages_ or other log files, e.g. **dmesg**? – Tommiie Sep 05 '18 at 10:46
  • no log about apache2 when i try start... /var/log/apache2/error.log have only failed connexion messages from client trying to connect on website... – Matrix Sep 05 '18 at 10:59
  • If your error.log file gets new log messages, then Apache is running. Can you confirm with **ss -lnt**? – Tommiie Sep 05 '18 at 11:00
  • interesting ! in fact I have new log like : `2018/09/05 13:19:28 [error] 933#933: *1762 connect() failed (111: Connection refused) while connecting to upstream, client: IP, server: mywebsite.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:88/favicon.ico", host: "mywebsite.com" ` – Matrix Sep 05 '18 at 11:21
  • So... can you confirm Apache is running? Do you have a listener on port 88 when you run **ss -lnt**? Also please include the configuration file as you're obviously not using the default config, given you're connecting on port 88. – Tommiie Sep 05 '18 at 11:22
  • but I have a nginx on port 80 with rerouting on apache on port 88, it's maybe for that ... `ps -aux | grep apache` have nothing. – Matrix Sep 05 '18 at 11:23
  • ss -int see only on port 80 (ngnix) – Matrix Sep 05 '18 at 11:24

2 Answers2

1

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
Tommiie
  • 5,627
  • 2
  • 12
  • 46
  • I have the same error with my conf or default conf, or default conf + modify the port to 88 : `apache2.service: Failed to run 'start' task: No such file or directory` – Matrix Sep 05 '18 at 11:54
  • Very late reply but... can you share your Apache configuration files? There must be something wrong in there. A reinstall not always removes all config files. – Tommiie Jan 02 '19 at 10:39
  • 1
    late, I have format my disk and now all works ^^ – Matrix Jan 02 '19 at 10:48
1

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
wazoox
  • 6,918
  • 4
  • 31
  • 63