[SOLVED] Unable to Start Apache

Issues related to applications and software problems
Entegeb
Posts: 6
Joined: 2017/06/01 14:40:57

[SOLVED] Unable to Start Apache

Post by Entegeb » 2017/06/01 15:19:30

I recently ran a yum update, and am now unable to start Apache. I am fairly new to Linux/CentOS so have gone through a few things I found online.

Running: "systemctl -l status httpd.service" gives me:

Code: Select all

 httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2017-06-01 14:38:46 CDT; 6min ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 13771 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 13769 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 13769 (code=exited, status=1/FAILURE)

Jun 01 14:38:46 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
Jun 01 14:38:46 localhost.localdomain httpd[13769]: [Thu Jun 01 14:38:46.095121 2017] [so:warn] [pid 13769] AH01574: module rewrite_module is already loaded, skipping
Jun 01 14:38:46 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jun 01 14:38:46 localhost.localdomain kill[13771]: kill: cannot find process ""
Jun 01 14:38:46 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
Jun 01 14:38:46 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
Jun 01 14:38:46 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
Jun 01 14:38:46 localhost.localdomain systemd[1]: httpd.service failed.
"journalctl -xe" gives me:

Code: Select all

Jun 01 14:33:34 localhost.localdomain sudo[13757]:     root : TTY=pts/0 ; PWD=/etc ; USER=root ; COMMAND=/sbin/h
Jun 01 14:38:46 localhost.localdomain polkitd[655]: Registered Authentication Agent for unix-process:13763:61635
Jun 01 14:38:46 localhost.localdomain systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Jun 01 14:38:46 localhost.localdomain httpd[13769]: [Thu Jun 01 14:38:46.095121 2017] [so:warn] [pid 13769] AH01
Jun 01 14:38:46 localhost.localdomain systemd[1]: httpd.service: main process exited, code=exited, status=1/FAIL
Jun 01 14:38:46 localhost.localdomain kill[13771]: kill: cannot find process ""
Jun 01 14:38:46 localhost.localdomain systemd[1]: httpd.service: control process exited, code=exited status=1
Jun 01 14:38:46 localhost.localdomain systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit httpd.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has failed.
--
-- The result is failed.
Jun 01 14:38:46 localhost.localdomain systemd[1]: Unit httpd.service entered failed state.
Jun 01 14:38:46 localhost.localdomain systemd[1]: httpd.service failed.
Jun 01 14:38:46 localhost.localdomain polkitd[655]: Unregistered Authentication Agent for unix-process:13763:616
lines 1776-1798/1798 (END)
My error_log contains the following:

Code: Select all

[Mon May 29 03:22:01.629074 2017] [auth_digest:notice] [pid 954] AH01757: generating secret for digest authentication ...
[Mon May 29 03:22:01.630584 2017] [lbmethod_heartbeat:notice] [pid 954] AH02282: No slotmem from mod_heartmonitor
[Mon May 29 03:22:01.661569 2017] [mpm_prefork:notice] [pid 954] AH00163: Apache/2.4.6 (CentOS) PHP/5.6.30 configured -- resuming normal operations
[Mon May 29 03:22:01.661601 2017] [core:notice] [pid 954] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Wed May 31 21:22:17.564593 2017] [mpm_prefork:notice] [pid 954] AH00170: caught SIGWINCH, shutting down gracefully
AH00015: Unable to open logs
AH00015: Unable to open logs
AH00015: Unable to open logs
AH00015: Unable to open logs
AH00015: Unable to open logs
[Thu Jun 01 14:33:34.214515 2017] [core:notice] [pid 13758] SELinux policy enabled; httpd running as context unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
[Thu Jun 01 14:33:34.235100 2017] [suexec:notice] [pid 13758] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Thu Jun 01 14:33:34.267818 2017] [so:warn] [pid 13758] AH01574: module rewrite_module is already loaded, skipping
[Thu Jun 01 14:33:34.269375 2017] [auth_digest:notice] [pid 13758] AH01757: generating secret for digest authentication ...
[Thu Jun 01 14:33:34.271080 2017] [lbmethod_heartbeat:notice] [pid 13758] AH02282: No slotmem from mod_heartmonitor
AH00015: Unable to open logs
AH00015: Unable to open logs
AH00015: Unable to open logs
AH00015: Unable to open logs
AH00015: Unable to open logs
AH00015: Unable to open logs
I am a bit stuck as to what to try next - any help would be much appreciated!
Last edited by Entegeb on 2017/06/01 21:31:44, edited 1 time in total.

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Unable to Start Apache

Post by TrevorH » 2017/06/01 15:25:24

You appear to have two problems, one less serious than the other. First the non-serious one:
Jun 01 14:38:46 localhost.localdomain httpd[13769]: [Thu Jun 01 14:38:46.095121 2017] [so:warn] [pid 13769] AH01574: module rewrite_module is already loaded, skipping
So somewhere in your configuration you have two places which say "LoadModule rewrite_module modules/mod_rewrite.so" and one of those will be the default place which is /etc/httpd/conf.modules.d/00-base.conf. Try running grep rewrite /etc/httpd/conf.modules.d/* and see how many places it is found in. Remove or comment the other one.

The more serious one is also stopping you from finding out anything more:
AH00015: Unable to open logs
Where have you told it to log? And what is the ownership and permissions of that location? If you moved the logs to somewhere other than /var/log/httpd and you have selinux enabled then you will probably need to tell selinux that it's ok for httpd to write there. If the ownership is incorrect or the permissions then fix it up.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Entegeb
Posts: 6
Joined: 2017/06/01 14:40:57

Re: Unable to Start Apache

Post by Entegeb » 2017/06/01 15:43:42

Thanks for the quick response!
TrevorH wrote:So somewhere in your configuration you have two places which say "LoadModule rewrite_module modules/mod_rewrite.so" and one of those will be the default place which is /etc/httpd/conf.modules.d/00-base.conf. Try running grep rewrite /etc/httpd/conf.modules.d/* and see how many places it is found in. Remove or comment the other one.
I ran the command and got the following:

Code: Select all

[root@localhost ~]# grep rewrite /etc/httpd/conf.modules.d/*
/etc/httpd/conf.modules.d/00-base.conf:LoadModule rewrite_module modules/mod_rewrite.so
Looks to me like there is only one?

Regarding the logs, they are set to "/etc/httpd/logs" however it looks like that is a symbolic link to /var/log/httpd.

The permissions for httpd are currently as follows:

Code: Select all

drwx------. 2 root  root     234 Jun  1  2017 httpd
Is this correct?

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Unable to Start Apache

Post by TrevorH » 2017/06/01 16:05:07

Looks to me like there is only one?
Check in /etc/httpd.conf.d too.

Permissions on /var/log/httpd look OK. What do you see if you run ls -laZ /var/log/httpd/ ?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

Entegeb
Posts: 6
Joined: 2017/06/01 14:40:57

Re: Unable to Start Apache

Post by Entegeb » 2017/06/01 16:12:27

Ah yes, there was another, I have commented that out.
TrevorH wrote:Permissions on /var/log/httpd look OK. What do you see if you run ls -laZ /var/log/httpd/ ?
The following:

Code: Select all

[root@localhost httpd]# ls -laZ /var/log/httpd/
drwx------. root root system_u:object_r:httpd_log_t:s0 .
drwxr-xr-x. root root system_u:object_r:var_log_t:s0   ..
-rw-r--r--. root root system_u:object_r:httpd_log_t:s0 access_log
-rw-r--r--. root root system_u:object_r:httpd_log_t:s0 error_log
-rw-r--r--. root root system_u:object_r:httpd_log_t:s0 error_log-20170508
-rw-r--r--. root root system_u:object_r:httpd_log_t:s0 error_log-20170514
-rw-r--r--. root root system_u:object_r:httpd_log_t:s0 error_log-20170521
-rw-r--r--. root root system_u:object_r:httpd_log_t:s0 error_log-20170529
-rw-r--r--. root root system_u:object_r:httpd_log_t:s0 snipeIT.error.log
-rw-r--r--. root root system_u:object_r:httpd_log_t:s0 snipeIT.error.log-20170601
-rw-r--r--. root root unconfined_u:object_r:httpd_log_t:s0 ystemctl daemon-reload

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Unable to Start Apache

Post by hunter86_bg » 2017/06/01 19:48:15

What's the output from

Code: Select all

apachectl configtest

Entegeb
Posts: 6
Joined: 2017/06/01 14:40:57

Re: Unable to Start Apache

Post by Entegeb » 2017/06/01 19:50:14

hunter86_bg wrote:What's the output from

Code: Select all

apachectl configtest

Code: Select all

Syntax OK
:)

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Unable to Start Apache

Post by hunter86_bg » 2017/06/01 19:56:43

check for clues in /var/log/httpd/error_log ...

Entegeb
Posts: 6
Joined: 2017/06/01 14:40:57

Re: Unable to Start Apache

Post by Entegeb » 2017/06/01 19:58:42

hunter86_bg wrote:check for clues in /var/log/httpd/error_log ...
My error log is in the first post, unfortunately there is a problem with access to it.

pjsr2
Posts: 614
Joined: 2014/03/27 20:11:07

Re: Unable to Start Apache

Post by pjsr2 » 2017/06/01 21:10:03

Are you using VirtualHosts in your configuration? VirtualHosts may have their own log files, which are usually not in the /etc/httpd/logs ( or /var/log/httpd ) directory.

You can start httpd manually and use strace to get a log file with traces of all files that httpd tries to open/access. This can help you identify which log file cannot be opened.

First stop httpd

Code: Select all

sudo systemctl stop httpd
Then use strace to trace all file open actions done by httpd:

Code: Select all

sudo strace -e trace=file -o/tmp/strace.out /usr/sbin/httpd -DFOREGROUND -X
The -X option lets httpd run without forking background tasks.
Kill the strace process after a couple of seconds and inspect the strace log file /tmp/strace.out to find all the path names of log files that httpd attempts to open. Check if all path components exist and directories/log files are writable.

Post Reply