Toma Tomov
Toma Tomov

Reputation: 1694

Why Apache stops when file error.log doesn't exist

Why Apache server stops work when the some path is set wrong or in my case - the file doesn't exist ? This is my configuration:

<VirtualHost *:80>
    ServerName toma-coreshop.webbuild.com
    DocumentRoot /home/projects/toma/toma-coreshop

    <Directory /home/projects/toma/toma-coreshop>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>
ErrorLog /home/projects/toma/toma-coreshop/logs/error.log
</VirtualHost>

Now the error.log file doesn't exist and the whole server drops. The other domains also don't work. Why is this behavior ? Appreciating any useful links also. Thank you in advance!

Upvotes: 0

Views: 1599

Answers (1)

Elvis Plesky
Elvis Plesky

Reputation: 3300

First of all, if the directory path specified in errorlog directive exists, Apache 2.4 will create a log file.

The issue occurs only when the directory is missing.

During Apache (re)start, it checks configuration for errors. The same can be done manually, when the configuration was modified with errors, but Apache was not restarted, thus still running:

# apachectl -t
(2)No such file or directory: AH02291: Cannot access directory '/var/www/example.com/nologs/' for error log of vhost defined at /etc/httpd/conf/plesk.conf.d/vhosts/example.com.conf:10
AH00014: Configuration check failed

Strace shows that during the restart, Apache checks all specified error log directories:

# strace /usr/sbin/httpd
...
stat("/etc/httpd/logs/", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
...
stat("/var/www/example.com/nologs/", 0x7ffff84f3140) = -1 ENOENT (No such file or directory)
write(2, "(2)No such file or directory: AH"..., 203(2)No such file or directory: AH02291: Cannot access directory '/var/www/example.com/nologs/' for error log of vhost defined at /etc/httpd/conf/plesk.conf.d/vhosts/example.com.conf:10
) = 190
write(2, "AH00014: Configuration check fai"..., 36AH00014: Configuration check failed
) = 36

It seems that being able to access the error log is pretty important for Apache to perform normally. At the same time, Apache does not take the liberty to create a full path to the log directory.

Other services, such as PHP-FPM, display the same behavior

Upvotes: 1

Related Questions