0

I can't start httpd on RHEL 7.

[root@machine]# systemctl restart httpd
Failed to restart httpd.service: Unit not found.

I tried...

yum update -y
yum install httpd -y
systemctl restart httpd

Same result. Apache config looks OK:

[root@machine]# httpd -t
Syntax OK

Red Hat Enterprise Linux Server release 7.7 (Maipo)


[root@machine me]# rpm -q httpd
httpd-2.4.6-90.el7.x86_64

...

[root@machine me]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2020-01-27 15:38:54 CST; 1 day 16h ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 36851 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 36849 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 36849 (code=exited, status=1/FAILURE)

Jan 27 15:38:54 faspbsy0002 httpd[36849]: (98)Address already in use: AH0007...0
Jan 27 15:38:54 faspbsy0002 httpd[36849]: (98)Address already in use: AH0007...0
Jan 27 15:38:54 faspbsy0002 httpd[36849]: no listening sockets available, sh...n
Jan 27 15:38:54 faspbsy0002 httpd[36849]: AH00015: Unable to open logs
Jan 27 15:38:54 faspbsy0002 systemd[1]: httpd.service: main process exited, ...E
Jan 27 15:38:54 faspbsy0002 kill[36851]: kill: cannot find process ""
Jan 27 15:38:54 faspbsy0002 systemd[1]: httpd.service: control process exite...1
Jan 27 15:38:54 faspbsy0002 systemd[1]: Failed to start The Apache HTTP Server.
Jan 27 15:38:54 faspbsy0002 systemd[1]: Unit httpd.service entered failed state.
Jan 27 15:38:54 faspbsy0002 systemd[1]: httpd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
5
  • did you try with service httpd start ?
    – BANJOSA
    Commented Jan 27, 2020 at 22:29
  • What is the output of rpm -q httpd? Possibly also rpm -ql httpd | grep service and systemctl list-unit-files | grep http. If those return results, does systemctl status httpd output anything? Were there any post-install errors after you initially installed httpd? Commented Jan 28, 2020 at 1:10
  • @GracefulRestart -- I will edit my question to add the output from those commands.
    – arnoldbird
    Commented Jan 29, 2020 at 14:28
  • Do journalctl -xf -l --unit httpd to see what errors it gets. The problem shown by your log is that the address is already in use, but the line is shortened. The -l will show you the full error. "Address already in use" probably means that there are earlier instances that have not shut down completely (IIRC, there is also a delay when a TCP socket is shut down and before it is released, so maybe you are not waiting long enough for the previous failed restart to clean up before retrying).
    – NickD
    Commented Jan 29, 2020 at 14:40
  • [root@faspbsy0002 me]# journalctl -xf -l --unit httpd ... Result at pastebin.com/UMb3Hd2s
    – arnoldbird
    Commented Jan 29, 2020 at 16:22

2 Answers 2

0

Unit not found seems to me that httpd is not serviced properly.

Try the following

systemctl is-enabled httpd
systemctl is-active httpd

If both return again unit not found, try to install httpd again, make a backup of your config first.

yum remove httpd

yum search apache
yum install httpd
11
  • systemctl is-enabled httpd -> disabled.
    – arnoldbird
    Commented Jan 29, 2020 at 14:31
  • systemctl is-active httpd -> failed
    – arnoldbird
    Commented Jan 29, 2020 at 14:32
  • After removing httpd, search apache and install httpd, I am still unable to start apache. You can see the output from my attempts to start apache, and from journalctl, at pastebin.com/tb5BQWDa
    – arnoldbird
    Commented Jan 29, 2020 at 15:06
  • you are trying to start a the http in a port that is already used by another service. Please provide the output of netstat -tulnp
    – BANJOSA
    Commented Jan 29, 2020 at 16:30
  • @BANJOSA -- Output at pastebin.com/szvXnn16
    – arnoldbird
    Commented Jan 29, 2020 at 16:46
0

The problem appears to be that I had two different versions of Apache installed: the standard version and one from Red Hat Software Collections.

[root@faspbsy0002 httpd24]# yum list installed | grep httpd
httpd.x86_64                  2.4.6-90.el7             @rhel-7-server-rpms      
httpd-tools.x86_64            2.4.6-90.el7             @rhel-7-server-rpms      
httpd24-httpd.x86_64          2.4.34-7.el7.1           @rhel-server-rhscl-7-rpms
httpd24-httpd-tools.x86_64    2.4.34-7.el7.1           @rhel-server-rhscl-7-rpms
httpd24-libcurl.x86_64        7.61.1-2.el7             @rhel-server-rhscl-7-rpms
httpd24-libnghttp2.x86_64     1.7.1-7.el7              @rhel-server-rhscl-7-rpms
httpd24-mod_ssl.x86_64        1:2.4.34-7.el7.1         @rhel-server-rhscl-7-rpms
httpd24-runtime.x86_64        1.1-18.el7               @rhel-server-rhscl-7-rpms

To restart Apache, I needed to do...

systemctl restart httpd24-httpd

And I should probably also remove the version of Apache I don't use.

I also discovered that httpd -V is misleading in this situation, because it gives the httpd_root and document_root of the standard Apache, but that was not the Apache in use.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .