为什么某些路径设置错误或我的情况下Apache服务器停止工作-文件不存在?这是我的配置:
<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>
现在error.log
文件不存在,整个服务器掉线了。其他域也不起作用。为什么会这样呢?也赞赏任何有用的链接。预先谢谢你!
答案 0 :(得分:1)
首先,如果errorlog
指令中指定的目录路径存在,Apache 2.4将创建一个日志文件。
仅当目录丢失时,才会出现此问题。
在Apache(重新)启动期间,它将检查配置中是否有错误。在修改配置时出现错误,但是Apache没有重新启动,因此仍然可以运行时,可以手动执行以下操作:
# 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显示,在重新启动期间,Apache检查所有指定的错误日志目录:
# 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
看来,能够访问错误日志对于Apache正常执行非常重要。同时,Apache不会随意创建日志目录的完整路径。
其他服务(例如PHP-FPM)显示相同的行为