Apache Won't Start after Adding SSL Certificates - apache

Hello so here is the problem
I have generated CSR on CentOS and purchased SSL on Comodo.
I have added following lines to ssl.conf
ServerName mydomain.com
DocumentRoot /var/www/html
SSLEngine on
SSLCertificateKeyFile /etc/pki/tls/certs/mydomain.key
SSLCertificateFile /etc/pki/tls/certs/mydomain.crt
SSLCACertificateFile /etc/pki/tls/certs/mydomainCA.crt
and following lines to httpd.conf
<VirtualHost *:80>
ServerName thedomain.com
Redirect "/" "https://thedomain.com/"
</VirtualHost>
After this when I do systemctl restart httpd it gives me following error:
Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl
-xe" for details.
and when I check journalctl -xe for details this is what it reads:
-- Subject: Unit httpd.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Unit httpd.service has finished starting up.
-- The start-up result is done. Nov 24 18:36:01 MyWay polkitd[568]: Unregistered Authentication Agent for unix-process:6639:684652621
(system bus name :1.4409, object path
/org/freedesktop/PolicyKit1/AuthenticationAgent, locale e Nov 24
18:36:04 MyWay sshd[6652]: Invalid user oracle from 80.241.211.237
port 54600 Nov 24 18:36:04 MyWay sshd[6652]: input_userauth_request:
invalid user oracle [preauth] Nov 24 18:36:04 MyWay sshd[6652]:
pam_unix(sshd:auth): check pass; user unknown Nov 24 18:36:04 MyWay
sshd[6652]: pam_unix(sshd:auth): authentication failure; logname=
uid=0 euid=0 tty=ssh ruser= rhost=vmi306916.contaboserver.net Nov 24
18:36:06 MyWay sshd[6652]: Failed password for invalid user oracle
from 80.241.211.237 port 54600 ssh2 Nov 24 18:36:06 MyWay sshd[6652]:
Received disconnect from 80.241.211.237 port 54600:11: Normal
Shutdown, Thank you for playing [preauth] Nov 24 18:36:06 MyWay
sshd[6652]: Disconnected from 80.241.211.237 port 54600 [preauth] Nov
24 18:36:16 MyWay sshd[6651]: Received disconnect from 112.85.42.94
port 31545:11: [preauth] Nov 24 18:36:16 MyWay sshd[6651]:
Disconnected from 112.85.42.94 port 31545 [preauth] Nov 24 18:36:18
MyWay polkitd[568]: Registered Authentication Agent for
unix-process:6655:684654361 (system bus name :1.4410
[/usr/bin/pkttyagent --notify-fd 5 --fallback], object path
/org/freedes Nov 24 18:36:18 MyWay systemd[1]: Stopping The Apache
HTTP Server...
-- Subject: Unit httpd.service has begun shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Unit httpd.service has begun shutting down. Nov 24 18:36:19 MyWay systemd[1]: Stopped The Apache HTTP Server.
-- Subject: Unit httpd.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Unit httpd.service has finished shutting down. Nov 24 18:36:19 MyWay 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. Nov 24 18:36:19 MyWay systemd[1]: httpd.service: main process exited, code=exited,
status=1/FAILURE Nov 24 18:36:19 MyWay kill[6667]: kill: cannot find
process "" Nov 24 18:36:19 MyWay systemd[1]: httpd.service: control
process exited, code=exited status=1 Nov 24 18:36:19 MyWay 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. Nov 24 18:36:19 MyWay systemd[1]: Unit httpd.service entered failed state. Nov 24 18:36:19 MyWay systemd[1]:
httpd.service failed. Nov 24 18:36:19 MyWay polkitd[568]: Unregistered
Authentication Agent for unix-process:6655:684654361 (system bus name
:1.4410, object path /org/freedesktop/PolicyKit1/AuthenticationAgent,
locale e [
So I have checked lot os solutions but this problems still exists, please note that when I comment out all changes in httpd.conf and ssl.conf apache starts working back normally.
Thanks all in advance

SOLVED
Renaming file to PEM helped the case, besides this I came across some other issues that were causing error ( looking ata apache logs helped me to solv them )
Memory for apache was full so I had to increase it.
I had duplicated SSLCertificateKeyFile in the ssl.conf file and I commented out the default file link.

Related

Unable to start httpd service on Centos 7 "GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject"

When trying to (re)start httpd service I get the following error:
** (pkttyagent:2574): WARNING **: 01:33:55.345: Unable to register authentication agent:
GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject Error registering authentication agent:
GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: Cannot determine user of subject (polkit-error-quark, 0) Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
Then
systemctl status httpd.service
sheds no light on the problem:
httpd.service - Web server Apache
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2020-07-22 01:33:55 BST; 26min ago
Process: 2578 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, status=1/FAILURE)
Jul 22 01:33:55 server... systemd[1]: Starting Web server Apache...
Jul 22 01:33:55 server... systemd[1]: httpd.service: control process exited, code=exited status=1
Jul 22 01:33:55 server... systemd[1]: Failed to start Web server Apache.
Jul 22 01:33:55 server... systemd[1]: Unit httpd.service entered failed state.
Jul 22 01:33:55 server... systemd[1]: httpd.service failed.
What might be causing this? Where should I look to debug?
[Thu Jul 23 05:40:44.885963 2020] [ssl:emerg] [pid 2877:tid 140514669713280] AH02565: Certificate and private key do not match
Looks like key and certificate do not match. Please check md5 of the key and cert file.
This usually happens when trying to restart a systemd service.
The workaround is as follows:
Run this as root
groupadd -g 23 nohidproc
usermod -a -G nohidproc polkitd
mount -o remount,rw,hidepid=2,gid=nohidproc /proc
systemctl restart polkit

httpd service starting although it is disabled to start on reboot

I'm using RHEL 7.4 OS. I have done systemctl disable httpd.service to disable auto start of httpd. It is disabled also.
[root#clustermrfc002 ~]# systemctl is-enabled httpd
disabled.
But on reboot httpd service is starting.
Jul 28 18:02:07 clustermrfc002.novalocal systemd[1]: Starting The Apache HTTP Server...
Jul 28 18:02:08 clustermrfc002.novalocal httpd[8732]: [Sat Jul 28 18:02:08.357617 2018] [core:warn] [pid 8732] AH00117: Ignoring deprecated use
Jul 28 18:02:08 clustermrfc002.novalocal systemd[1]: Started The Apache HTTP Server.
which is causing problem in rhel 7 pacemaker cluster, below error is seen.
Jul 28 18:12:23 clustermrfc001 pengine[7420]: error: Resource MNGT_httpd_rhcdDaemon (systemd::httpd) is active on 2 nodes attempting recovery
Check the output of "chkconfig" and review its runlevel.
Or, check if any other service for HTTPD is enabled using "systemctl list-unit-files", if enabled, disable and verify
Although httpd.service is disabled to start on boot, its started by network.target as a dependency.
Jul 26 15:02:41 localhost.localdomain systemd[1]: Starting Network.
Jul 26 15:02:41 localhost.localdomain systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
Jul 26 15:02:41 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
Jul 26 15:02:41 localhost.localdomain systemd[1]: Starting Dynamic System Tuning Daemon...
Jul 26 15:02:41 localhost.localdomain systemd[1]: Starting PostgreSQL database server...
Jul 26 15:02:41 localhost.localdomain systemd[1]: Starting Simple Network Management Protocol (SNMP) Daemon....
Jul 26 15:02:41 localhost.localdomain systemd[1]: Starting
The Apache HTTP Server...

Failed to start The Apache HTTP Server

Server is Cent OS.
The httpd was working properly that is why I shut down the whole server to take snapshot. After the reboot the httpd was not working anymore, here is error from jorunalctl:
-- Unit httpd.service has begun starting up.
Mar 16 12:47:49 ragnar01.novalocal httpd[2350]: httpd (pid 2322) already running
Mar 16 12:47:49 ragnar01.novalocal kill[2351]: kill: cannot find process ""
Mar 16 12:47:49 ragnar01.novalocal systemd[1]: httpd.service: control process exited, code=exited status=1
Mar 16 12:47:49 ragnar01.novalocal 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.
Mar 16 12:47:49 ragnar01.novalocal systemd[1]: Unit httpd.service entered failed state.
Mar 16 12:47:49 ragnar01.novalocal systemd[1]: httpd.service failed.
Mar 16 12:47:49 ragnar01.novalocal polkitd[779]: Unregistered Authentication Agent for unix-process:2335:24998 (system bus name :1.13, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
Mar 16 12:48:00 ragnar01.novalocal sshd[2332]: Connection closed by 123.183.209.139 [preauth]
I will be glad for all the ideas to start it again.

Apache failing to start after install

I have just starting using Linode with Centos 7. I have never created my own server to host a website so apologies in advance.
I have read every stackoverflow (and other sites) Q&A's for this problem and I can't seem to fix it.
I installed Apache2 and followed the tutorial on Linodes website. The server doesn't start and I get these following errors:
When I run - systemctl status httpd.service
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: failed (Result: exit-code) since Sun 2015-11-08 16:18:47 GMT; 10s ago
Process: 15662 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 15661 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=0/SUCCESS)
Main PID: 15661 (code=exited, status=0/SUCCESS)
Nov 08 16:18:47 london systemd[1]: Starting The Apache HTTP Server...
Nov 08 16:18:47 london httpd[15661]: httpd (pid 15652) already running
Nov 08 16:18:47 london kill[15662]: kill: cannot find process ""
Nov 08 16:18:47 london systemd[1]: httpd.service: control process exited, code=exited status=1
Nov 08 16:18:47 london systemd[1]: Failed to start The Apache HTTP Server.
Nov 08 16:18:47 london systemd[1]: Unit httpd.service entered failed state.
When I run - journalctl -xn
Logs begin at Thu 2015-10-22 20:33:26 BST, end at Sun 2015-11-08 16:18:47 GMT.
Nov 08 16:10:01 london systemd[1]: Starting Session 2857 of user root.
Subject: Unit session-2857.scope has begun with start-up
Defined-By: systemd
Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Unit session-2857.scope has begun starting up.
Nov 08 16:10:01 london systemd[1]: Started Session 2857 of user root.
Subject: Unit session-2857.scope has finished start-up
Defined-By: systemd
Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Unit session-2857.scope has finished starting up.
The start-up result is done.
Nov 08 16:10:01 london CROND[15635]: (root) CMD (/usr/lib64/sa/sa1 1 1)
Nov 08 16:15:02 london sshd[15647]: Received disconnect from 43.229.53.26: 11: [preauth]
Nov 08 16:18:47 london systemd[1]: Starting The Apache HTTP Server...
Subject: Unit httpd.service has begun with start-up
Defined-By: systemd
Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Unit httpd.service has begun starting up.
Nov 08 16:18:47 london httpd[15661]: httpd (pid 15652) already running
Nov 08 16:18:47 london kill[15662]: kill: cannot find process ""
Nov 08 16:18:47 london systemd[1]: httpd.service: control process exited, code=exited status=1
Nov 08 16:18:47 london 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.
I have absolutely no idea and can't see where I am going wrong. Can someone help at all??
Many thanks!

CentOS 7 apachectl httpd.service fails to start

I'm building https://github.com/devopsgroup-io/catapult-release-management and every once in a while trying to apachectl start an error of:
Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.
systemctl status httpd.service outputs:
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: failed (Result: exit-code) since Wed 2015-07-15 19:25:23 EDT; 4s ago
Process: 3247 ExecStop=/bin/kill -WINCH ${MAINPID} (code=exited, status=1/FAILURE)
Process: 3246 ExecStart=/usr/sbin/httpd $OPTIONS -DFOREGROUND (code=exited, status=1/FAILURE)
Main PID: 3246 (code=exited, status=1/FAILURE)
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: Starting The Apache HTTP Server...
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jul 15 19:25:23 devopsgroup.io-dev-redhat kill[3247]: kill: cannot find process ""
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: httpd.service: control process exited, code=exited status=1
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: Failed to start The Apache HTTP Server.
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: Unit httpd.service entered failed state.
and journalctl -xn outputs:
-- Logs begin at Wed 2015-07-15 19:23:53 EDT, end at Wed 2015-07-15 19:25:23 EDT. --
Jul 15 19:25:11 devopsgroup.io-dev-redhat sshd[3196]: pam_unix(sshd:session): session opened for user vagrant by (uid=0)
Jul 15 19:25:17 devopsgroup.io-dev-redhat sudo[3221]: vagrant : TTY=pts/0 ; PWD=/home/vagrant ; USER=root ; COMMAND=/bin/su -l
Jul 15 19:25:17 devopsgroup.io-dev-redhat su[3222]: (to root) vagrant on pts/0
Jul 15 19:25:17 devopsgroup.io-dev-redhat su[3222]: pam_unix(su-l:session): session opened for user root by vagrant(uid=0)
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: Starting The Apache HTTP Server...
-- Subject: Unit httpd.service has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit httpd.service has begun starting up.
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: httpd.service: main process exited, code=exited, status=1/FAILURE
Jul 15 19:25:23 devopsgroup.io-dev-redhat kill[3247]: kill: cannot find process ""
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: httpd.service: control process exited, code=exited status=1
Jul 15 19:25:23 devopsgroup.io-dev-redhat 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.
Jul 15 19:25:23 devopsgroup.io-dev-redhat systemd[1]: Unit httpd.service entered failed state.
Any ideas?
This was due to /etc/httpd/conf/httpd.conf being appended with more than 20 duplicate lines of IncludeOptional sites-enabled/*.conf
This is a bug in apachectl configtest as it reports correct configuration and does not provide a traceable error.