Failed Apache2 start, no error log
Asked Answered
Y

13

43

I would restart Apache2 but there comes an Error

$ sudo service apache2 start

Starting web server apache2

Action 'start' failed.
The Apache error log may have more information.

But all error logs in "/var/log/apache2/" are empty.

Edit: The Files are at "/var/log/apache2" and there are several entries from previous Problems but this Task doesn't create any new etry ...

Where is the Problem?


I've Solved the Problem!

It was a error in the SSL Certificate and the path to the "error.log" are changed in the vHost configuration.

If you don't need SSL (i don't because i'm running a local system) simply disable all vHost HTTPS/SSL entrys in the configuration by command line for line out.

Yulandayule answered 24/9, 2013 at 7:57 Comment(8)
check syslog for errorsFlowerdeluce
Have you space on the disk?Flowerdeluce
Just a comment: is the server stopped? If not, it will fail if you run sudo service apache2 start. For a restart it should be: sudo service apache2 restartFlowerdeluce
The server is down because it won't start at bootingYulandayule
is there any other error is syslog that can affect apache?Flowerdeluce
Nothing about apache2 or Network or something else ...Yulandayule
I haved a problem and solved by using sudo /etc/init.d/apache2 restart and not service apache2 restartVerve
Had an ssl cert where the cert didn't match the key and that made apache fail on start. I made sure the cert and the key matched and viola.Ahem
B
14

Thanks, Tim! Big stumper for me. A few other details others may find helpful:

(Apache2 on Ubuntu 12.04)

I have two sites running on the same server and had just updated the SSL cert for one of them. Upon restarting the server, I got that cryptic message and neither site worked (obviously). I too found the redirect for the log files in the config files. I tracked that down and found the issue (in the log file for the site I had just updated).

My config files are located in /etc/apache2/sites-available

vim or cat the file (cat {filename}) and look for the ErrorLog line. That tells you where to look on your server. cat that file and the error message I found was:

[error] Unable to configure RSA server private key
[error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[warn] RSA server certificate CommonName (CN) `<snip>.com' does NOT match server name!?

I had copied one of my cert files to the wrong directory. I simply moved it to the correct directory and everything was fine on the next start. (tip: where those file should be is also in the config file ;)

Batfish answered 18/3, 2014 at 21:31 Comment(0)
G
26

Syntax errors in the config file seem to cause problems. I found what the problem was by going to the directory and excuting this from the command line.

httpd -e info 

This gave me the error

Syntax error on line 156 of D:/.../Apache Software Foundation/Apache2.2/conf/httpd.conf:
Invalid command 'PHPIniDir', perhaps misspelled or defined by a module not included in the server configuration
Gorblimey answered 8/2, 2015 at 10:47 Comment(3)
Thanks for this. I don't live in the Apache world a lot. Spent the last two days trying to get SSL working-e infoPindus
This command got me past my initial issues, which was a bunch of syntax issues in the bitnami distribution I was working with. This at least got me to my next error :)Pindus
You can also append this if starting via custom service e.g ExecStart=/usr/sbin/apache2 $OPTIONS -e INFO -DFOREGROUNDComplicity
R
23

I also just ran in to a similar problem, that is service apache2 reload fails but prints no useful information. This is because the script in /etc/init.d/apache (on Debian, at least) eats the output of the apache2ctl configtest command it runs to sanitize the Apache config.

An easy solution to get a more meaningful explanation for the failure is to run apache2ctl configtest again yourself, which will print the (hopefully useful) error messages to the console.

Rodrickrodrigez answered 21/10, 2014 at 7:21 Comment(2)
"eats the output of..." - great :)Mansour
my apache2ctl configtest says Syntax OK but apach is not starting naymore :((Decline
B
14

Thanks, Tim! Big stumper for me. A few other details others may find helpful:

(Apache2 on Ubuntu 12.04)

I have two sites running on the same server and had just updated the SSL cert for one of them. Upon restarting the server, I got that cryptic message and neither site worked (obviously). I too found the redirect for the log files in the config files. I tracked that down and found the issue (in the log file for the site I had just updated).

My config files are located in /etc/apache2/sites-available

vim or cat the file (cat {filename}) and look for the ErrorLog line. That tells you where to look on your server. cat that file and the error message I found was:

[error] Unable to configure RSA server private key
[error] SSL Library Error: 185073780 error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch
[warn] RSA server certificate CommonName (CN) `<snip>.com' does NOT match server name!?

I had copied one of my cert files to the wrong directory. I simply moved it to the correct directory and everything was fine on the next start. (tip: where those file should be is also in the config file ;)

Batfish answered 18/3, 2014 at 21:31 Comment(0)
M
9

in the apache virtualhost you have to define the path to the error log file. when apache2 start for the first time it will create it automatically.

for example ErrorLog "/var/www/www.localhost.com/log-apache2/error.log" in the apache virtualhost..

Moment answered 24/9, 2013 at 8:4 Comment(4)
No the Error files are at "/var/log/apache2" and there are serveral errors from previous Problems. But This Start-Attemp doesn#t create new entrys in any error logYulandayule
if the file exist, may be you have a space problem with the disk , check that tooMoment
is it the same user created the previous logs or not, it can be the users authorization to create the log file. i got the same issue before due to the user problemMoment
Yes. All entrys are from one userYulandayule
C
3

If we have no entries in log files then we can try to debug apache2 using this command:

$ apache2 -S

or

$ apache2 -e debug

Possible output:

[Fri Apr 05 04:04:59.682880 2019] [core:warn] [pid 11086] 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
Chlorous answered 5/4, 2019 at 2:9 Comment(1)
This is the expected output if you run apache2 without sourcing /etc/apache2/envvars first.Mann
V
2

On XAMPP use

D:\xampp\apache\bin>httpd -t -D DUMP_VHOSTS

This will yield errors in your configuration of the virtual hosts

Velamen answered 26/1, 2017 at 12:32 Comment(0)
C
1

I ran into this problem on the Raspberry Pi. After trying everything but a reinstall, on a whim, I deleted /var/run/apache2/apache2.pid. I restarted Apache and everything worked. Not sure how to explain that.

Castilian answered 14/8, 2018 at 11:45 Comment(0)
E
1

Try to disable SElinux or configuration virtualhost for SElinux

to configuration with SElinux https://muchbits.com/apache-selinux-vhosts.html

to disable SElinux https://linuxize.com/post/how-to-disable-selinux-on-centos-7/

Eversole answered 7/12, 2018 at 7:13 Comment(0)
T
0

I ran into this exact issue today. I had copied the entire /etc/httpd from RHEL 6 and put it onto a CentOS 6 system, and ensured all RPMs were installed.

Anytime apache would be started, it would silently fail. It took an strace to find the culprit: I was using CustomLog to call a program that was not installed on the target system. Once I installed the expected program, Apache HTTP Server started right up.

Thorne answered 15/2, 2017 at 18:49 Comment(0)
M
0

You have following ways to make it work:

  1. Delete /var/run/apache2/apache2.pid then check if its working

  2. You can disable SELinux and then check if it works. You can disable SELinux permanantly or temporarily by using https://linux4one.com/how-to-disable-selinux-on-centos-7/ tutorial

Moreen answered 11/6, 2019 at 10:14 Comment(0)
V
0

On Apache on Linux there might be a problem that the configuration cannot be checked because of a problem with environment variables not being set. This is a false positive which only occurs when running apache2 -S from commandline (See previous answer from @simhumileco). For instance Config variable ${APACHE_RUN_DIR} is not defined.

In order to fix this run source /etc/apache2/envvars from the commandline and then run `apache2 -S' to get to the real (possible) problems.

root@fileserver:~# apache2 -S
[Thu Apr 30 10:42:06.822719 2020] [core:warn] [pid 24624] 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
root@fileserver:~# source /etc/apache2/envvars
root@fileserver:/root# apache2 -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
<----snip---->
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex ldap-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
root@fileserver:/root#
Velamen answered 30/4, 2020 at 8:44 Comment(0)
S
0

I have solved this same problem while configuring django in python with wsgi , I had installed libapache2-mod-python and libapache2-mod-wsgi-py3 at once ,so I removed libapache2-mod-python then it works fine for me

Satiny answered 18/6, 2022 at 22:10 Comment(0)
H
0

solution on kali linux

httpd -e info

then i got this output

Failed to start apache2.service: Unit apache2.service is masked.

i removed mu ip mask then it worked properly

Hoad answered 16/10, 2022 at 20:28 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Robbins

© 2022 - 2024 — McMap. All rights reserved.