Debugging Apache on Debian, where are the error logs?
I'm using a Debian server that already has Apache, mod_wsgi and a bunch of virtual hosts successfully running on it.
I installed my forum app (Django's OSQA) and following the OSQA instructions, I then created an Apache config file that specified ServerName
as the new sub-domain. I also created a .wsgi file for the app, and pointed WSGIScriptAlias
at it. I then restarted Apache.
However, when I go to the new sub-domain, I get a 404 error message.
Am I missing a step above? Or is simply creating a new Apache config file in sites-available
enough to tell Apache about a new sub-domain?
If there's something else going wrong, how can I debug it? The ErrorLog
and CustomLog
specified in the config file are both blank. apache2.conf
, which I guess is Apache-wide configuration, specifies ErrorLog /var/log/apache2/error.log
, but this is yet another blank file.
Solution 1:
There are a lot of online resources for Apache. Did you try searching Google to find the answers yourself?
When I searched Google a few months ago, I found the following information:
ErrorLog /var/log/apache2/error.log
AccessLog /var/log/apache2/access.log
start/stop /etc/init.d/apache2 (start|stop|restart|reload|force-reload|start-htcacheclean|stop-htcacheclean)
Solution 2:
The first post is not correct for all cases on Debian. It depends on how you have installed the package, whether that is via apt or by compiling from source.
To find out where the logs are, according to how Apache says it was instructed to generate logs you will want to run the following command:
/usr/sbin/apachectl -V
some distributions of linux create a symlink called /usr/sbin/apacheVERctl where VER is 2 or 1.3 or whatever. Debian puts the actual file in /usr/sbin/ so try the above command and you will see something like:
/usr/sbin/apachectl -V
Server version: Apache/2.2.3
<removed for brevity>
-D DEFAULT_PIDLOG="run/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_LOCKFILE="logs/accept.lock"
-D DEFAULT_ERRORLOG="logs/error_log" <<=== default log files stored in "logs/" which is relative to /usr/local/apache<VER>/logs on this server==>
-D SERVER_CONFIG_FILE="conf/httpd.conf"
As you can see, my logs are in /usr/local/apache2/error_log. Depending on how the server was compiled the --prefix flag might have been pointed somewhere else. Your best bet is to run that command and look for the error_log using find.
find / -iname name_of_error_log_file_that_apachectl_spit_out
You might have to do a find / -iname apachectl or various permutations thereof to find where the binary is. Sometimes it is called /usr/sbin/httpd. Just make sure you know the find command and you will figure it out.
Google searching will not always give you the right answers so it is critical to read the documentation for your services.
Also, after reviewing the document, if you went through the entire document, you have already configured logging for the /nimda path so logs for nimda go here:
<cut above config lines>
CustomLog /var/log/httpd/OSQA/access_log common
ErrorLog /var/log/httpd/OSQA/error_log
</VirtualHost>
And for SSL, the logs appear to be going to the same place:
(optional) run admin interface under https ServerAdmin [email protected] DocumentRoot /path/to/osqa-site ServerName example.com SSLEngine on SSLCertificateFile /path/to/ssl-certificate/server.crt SSLCertificateKeyFile /path/to/ssl-certificate/server.key WSGIScriptAlias / /path/to/osqa-site/osqa.wsgi CustomLog /var/log/httpd/OSQA/access_log common ErrorLog /var/log/httpd/OSQA/error_log DirectoryIndex index.html
Please check
/usr/local/apache<VER>/logs
on the server maybe even
/usr/local/httpd/*, /var/log/httpd or /var/log/apache<ver>.
Different Linux distributions have different places they store logs.
The logs are not always in /var/log/apache/* or /var/log/httpd
Sometimes they are in /var/log/httpd/, sometimes people compile Apache from source and the apache variable DEFAULT_ERRORLOG gets set differently so error log is in one place while access_log is in another. Sometimes the files have different names too. Sometimes people configure different vhosts to store logs in different places because they have a bunch of domains and they do not want all of the other customers on the box to see the logs for other domains because that might expose critical information. The first post is not going to work in all cases.
Google cannot answer every question and telling someone "google it" in so many words is not always the best answer.
A person might use Redhat, which puts the logs in a different place when installed from a Redhat distributed RPM.