2

I was trying to configure hosting 2 websites on my EC2 instance using VirtualHosts (Apache2). After setting the two VirtualHosts, I'm unable to restart the apache2 service. When I try to do that, I get this error:

Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.

"systemctl status apache2.service" returns this:

* apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           `-apache2-systemd.conf
   Active: failed (Result: exit-code) since Mon 2020-05-11 16:51:42 UTC; 1min 2s ago
  Process: 18831 ExecStart=/usr/sbin/apachectl start (code=exited, status=1/FAILURE)
 Main PID: 27500 (code=exited, status=0/SUCCESS)

May 11 16:51:42 ip-172-31-39-99 systemd[1]: Starting The Apache HTTP Server...
May 11 16:51:42 ip-172-31-39-99 apachectl[18831]: Action 'start' failed.
May 11 16:51:42 ip-172-31-39-99 apachectl[18831]: The Apache error log may have more information.
May 11 16:51:42 ip-172-31-39-99 systemd[1]: apache2.service: Control process exited, code=exited status=1
May 11 16:51:42 ip-172-31-39-99 systemd[1]: apache2.service: Failed with result 'exit-code'.
May 11 16:51:42 ip-172-31-39-99 systemd[1]: Failed to start The Apache HTTP Server.

and "journalctl -xe" returns this:

-- Unit apache2.service has begun starting up.
May 11 16:51:42 ip-172-31-39-99 apachectl[18831]: Action 'start' failed.
May 11 16:51:42 ip-172-31-39-99 apachectl[18831]: The Apache error log may have more information.
May 11 16:51:42 ip-172-31-39-99 systemd[1]: apache2.service: Control process exited, code=exited status=1
May 11 16:51:42 ip-172-31-39-99 sudo[18828]: pam_unix(sudo:session): session closed for user root
May 11 16:51:42 ip-172-31-39-99 systemd[1]: apache2.service: Failed with result 'exit-code'.
May 11 16:51:42 ip-172-31-39-99 systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: Unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit apache2.service has failed.
--
-- The result is RESULT.
May 11 16:51:59 ip-172-31-39-99 sshd[18868]: Invalid user www from 69.158.207.141 port 51665
May 11 16:51:59 ip-172-31-39-99 sshd[18868]: Received disconnect from 69.158.207.141 port 51665:11: Normal Shutdown, Thank you for playing [preauth]
May 11 16:51:59 ip-172-31-39-99 sshd[18868]: Disconnected from invalid user www 69.158.207.141 port 51665 [preauth]
May 11 16:52:35 ip-172-31-39-99 sshd[18870]: Invalid user demo from 69.158.207.141 port 56795
May 11 16:52:35 ip-172-31-39-99 sshd[18870]: Received disconnect from 69.158.207.141 port 56795:11: Normal Shutdown, Thank you for playing [preauth]
May 11 16:52:35 ip-172-31-39-99 sshd[18870]: Disconnected from invalid user demo 69.158.207.141 port 56795 [preauth]
May 11 16:53:11 ip-172-31-39-99 sshd[18875]: Invalid user zhangfeng from 69.158.207.141 port 33692
May 11 16:53:11 ip-172-31-39-99 sshd[18875]: Received disconnect from 69.158.207.141 port 33692:11: Normal Shutdown, Thank you for playing [preauth]
May 11 16:53:11 ip-172-31-39-99 sshd[18875]: Disconnected from invalid user zhangfeng 69.158.207.141 port 33692 [preauth]
May 11 16:53:47 ip-172-31-39-99 sshd[18878]: Invalid user centos from 69.158.207.141 port 38822
May 11 16:53:47 ip-172-31-39-99 sshd[18878]: Received disconnect from 69.158.207.141 port 38822:11: Normal Shutdown, Thank you for playing [preauth]
May 11 16:53:47 ip-172-31-39-99 sshd[18878]: Disconnected from invalid user centos 69.158.207.141 port 38822 [preauth]
May 11 16:53:58 ip-172-31-39-99 sshd[18880]: Received disconnect from 222.186.30.35 port 47135:11:  [preauth]
May 11 16:53:58 ip-172-31-39-99 sshd[18880]: Disconnected from authenticating user root 222.186.30.35 port 47135 [preauth]

I looked around and was told to run "apache2ctl configtest" returns "Syntax OK". And someone got more error info by running "apache2 --help" which returns this:

(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
AH00015: Unable to open logs

Looking around further, I was told to use "sudo apache2 --help" which gives this error:

  [Mon May 11 17:01:39.505293 2020] [core:warn] [pid 18920] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
apache2: Syntax error on line 80 of /etc/apache2/apache2.conf: DefaultRuntimeDir must be a valid directory, absolute or relative to ServerRoot

But Apache2 is properly installed, I tried "source /etc/apache2/envvars" but it doesn't seem to do anything. Why is this error occuring and how do I get rid of it? Can you guys help me out? Thanks in advance.

6
  • 1
    And what's the 80th line of /etc/apache2/apache2.conf? What the DefaultRuntimeDir and is it a valid directory? May 11, 2020 at 17:28
  • It is : DefaultRuntimeDir ${APACHE_RUN_DIR}, this is set as default by apache2 while installing as far as I know. So it must be valid. May 11, 2020 at 17:51
  • 1
    Don't assume. Check it from where the variable is set, or whether it's set at all. May 11, 2020 at 18:58
  • When you run "sudo apache2 --help", APACHE_RUN_DIR is undefined. For why Apache fails to start by systemd, look in Apache's error log. May 11, 2020 at 19:55
  • Please share with us the virtualhost file configurations where you have defined the two websites.
    – allexiusw
    May 12, 2020 at 9:03

0

You must log in to answer this question.

Browse other questions tagged .