Apache Not Working

General support questions
patricklunney
Posts: 2
Joined: 2017/12/04 18:29:39

Apache Not Working

Postby patricklunney » 2017/12/04 18:52:13

Hi all, I've spent hours troubleshooting my apache config and browsed many forums, but have hit a roadblock.
I took the same httpd.conf file from a working apache server and am trying to use the IP until I get the DNS changed. I don't expect the sites to work yet because of the OpenID Connect setup but I should at least be able to start apache and hit index.html.

Here are the error logs:

Code: Select all

# service httpd start
Redirecting to /bin/systemctl start httpd.service
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.


Code: Select all

# systemctl status httpd.service
● 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 2017-12-04 18:33:51 UTC; 21s ago
     Docs: man:httpd(8)
           man:apachectl(8)
  Process: 30008 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
  Process: 30007 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
 Main PID: 30007 (code=exited, status=1/FAILURE)

Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: Starting The Apache HTTP Server...
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Dec 04 18:33:51 ip-10-227-82-72 kill[30008]: kill: cannot find process ""
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: httpd.service: control process exited, code=exited status=1
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: Failed to start The Apache HTTP Server.
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: Unit httpd.service entered failed state.
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: httpd.service failed.


Code: Select all

# less journalctl -xe
journalctl: No such file or directory
-xe: No such file or directory
[root@ip-10-227-82-72 conf]# journalctl -xe
Dec 04 18:26:02 ip-10-227-82-72 kill[29981]: kill: cannot find process ""
Dec 04 18:26:02 ip-10-227-82-72 systemd[1]: httpd.service: control process exited, code=exited status=1
Dec 04 18:26:02 ip-10-227-82-72 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.
Dec 04 18:26:02 ip-10-227-82-72 systemd[1]: Unit httpd.service entered failed state.
Dec 04 18:26:02 ip-10-227-82-72 systemd[1]: httpd.service failed.
Dec 04 18:26:02 ip-10-227-82-72 polkitd[6773]: Unregistered Authentication Agent for unix-process:29964:2667895 (system bus name :1.51, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_U
Dec 04 18:33:51 ip-10-227-82-72 polkitd[6773]: Registered Authentication Agent for unix-process:29991:2714791 (system bus name :1.52 [/usr/bin/pkttyagent --notify-fd 5 --fallback], object path /org/freedeskto
Dec 04 18:33:51 ip-10-227-82-72 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.
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Dec 04 18:33:51 ip-10-227-82-72 kill[30008]: kill: cannot find process ""
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: httpd.service: control process exited, code=exited status=1
Dec 04 18:33:51 ip-10-227-82-72 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.
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: Unit httpd.service entered failed state.
Dec 04 18:33:51 ip-10-227-82-72 systemd[1]: httpd.service failed.
Dec 04 18:33:51 ip-10-227-82-72 polkitd[6773]: Unregistered Authentication Agent for unix-process:29991:2714791 (system bus name :1.52, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_U
lines 1180-1213/1213 (END)


I do have virtual hosts set up in sites-enabled. Here are the important parts in httpd.conf:

Code: Select all



# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
IncludeOptional sites-enabled/*.conf
AddDefaultCharset utf-8


And the sites-enabled.conf files look like this:

Code: Select all

<VirtualHost *:80>
   ServerName 10.227.82.72
   DocumentRoot /var/www/sites/
   ErrorLog /var/www/sites/error.log
   CustomLog /var/www/sites/requests.log combined
</VirtualHost>


Let me know if I can provide anything else.

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

Re: Apache Not Working

Postby hunter86_bg » 2017/12/04 21:58:17

Shouldn't ServerName be the dns entry your client's will be using ?
Run

Code: Select all

apachectl configtest
in order to find what is the issue.

User avatar
TrevorH
Forum Moderator
Posts: 21182
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache Not Working

Postby TrevorH » 2017/12/04 22:59:17

Try restorecon -RFv /etc/httpd/ and see if that helps.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

patricklunney
Posts: 2
Joined: 2017/12/04 18:29:39

Re: Apache Not Working

Postby patricklunney » 2017/12/05 04:05:10

I actually got it to work by commenting out the custom logs.

Code: Select all

<VirtualHost *:80>
   ServerName 10.227.82.72
   DocumentRoot /var/www/sites/
   # ErrorLog /var/www/sites/error.log
   # CustomLog /var/www/sites/requests.log combined
</VirtualHost>


And that did it. Any idea why that would cause an issue?

lspiehler
Posts: 3
Joined: 2017/12/03 21:45:03

Re: Apache Not Working

Postby lspiehler » 2017/12/05 04:58:07

Make sure the path /var/www/sites/ exists. Seems more appropriate for them to be somewhere like /var/log/httpd/sites/.

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

Re: Apache Not Working

Postby hunter86_bg » 2017/12/05 05:02:40

Selinux prevents the apache to write outside the predefined constraints.
You can use

Code: Select all

semanage fcontext -a -t (context of /var/log/httpd) "/var/www/sites/*.log" && restorecon -RFvv /var/www/sites/
.

Note:I'm not sure if the regex is OK, you have to test it.Also replace the context type.

User avatar
TrevorH
Forum Moderator
Posts: 21182
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Apache Not Working

Postby TrevorH » 2017/12/05 07:19:01

Don't write logs under /var/www as selinux sees writes there as an attempt to compromise your httpd server. Write them under /var/log/httpd where they're meant to be.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke