2

So I keep getting the following error in apache logs:

sendmail: fatal: open /etc/postfix/main.cf: No such file or directory

And I'm trying to figure out where/when it's being attempted, but I can't figure out where in the apache logs I'm supposed to change the conf in order to get this to show more information. Any ideas?

I have the following in my apache2.conf (which I assumed would make it dislay the proper formatting):

ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

Note, I don't want to fix the error itself (aka make it so that the file exists, fix postfix etc.) I just want to know what is trying to execute the sendmail command.

1 Answer 1

3

Your apache try to send email. Maybe from PHP or CGI scripts, but not by itself. If the script is chrooted, it can not access to /etc/postfix/main.cf and return the error. You will not see anything in the logs (except on small sites where you will be able to found the URL asked by the user at the same time that the error line).

You can maybe add a custom log (with %{format}t option)[1], but you will not have it in error log.

Edit : You can also redirect the Error log to Syslog to have the date added by syslog : ErrorLog syslog:local1

[1] https://httpd.apache.org/docs/trunk/mod/mod_log_config.html#formats

7
  • That's my question. How do I make it give a custom log? As you see above, I already have LogFormat in place, but it's still not formatting it to give the date. I at least need to have the date so that I can then go through the access logs and see which URL is causing problems. Feb 15, 2016 at 3:31
  • From the doc : Timestamp including milliseconds "%{%d/%b/%Y %T}t.%{msec_frac}t %{%z}t". Do you enable a type of custom log in your virtualhost : CustomLog /var/log/apache2/access.log combined
    – Dom
    Feb 15, 2016 at 7:32
  • I have two virtual hosts with CustomLogs, but the error above (or any error at all) appears for them. I only get the errors in my general apache log. Feb 15, 2016 at 12:39
  • It is exactly what I wrote : the errors are always global, and can not be tuned. The access logs are split by VirtualHost and the format can be changed.
    – Dom
    Feb 15, 2016 at 13:48
  • Right. I think you're not understanding what I'm saying. I can't check my access logs because I don't know when the error is being produced. I can alter my access logs all I want, but unless I know WHEN the error happened I can't do anything.... My ENTIRE question is how do I make it so that the error tells me when it occured?...... That's all I want to know. When did the above error occur? As you see, I already have formats for the log, so I know how to format. I just don't see what I'm supposed to format since all the formatting I've done hasn't changed a thing. Feb 16, 2016 at 3:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .