大网数据广告活动
服务器运维问答

Apache can't find directories in symlinked '/var'

· 52CE 我爱测

I have the following directories, where /data is the mount point for a data partition, and /var is a symlink: lrwxrwxrwx 1 root root 9 Nov 20 13:25 /var -> /data/var lrwxrwxrwx 1 root root 9 Nov 20 23:41 /var/lock -> /run/lock dr…

问题原文

原帖链接 · Roger Dueck · CC BY-SA 4.0

I have the following directories, where /data is the mount point for a data partition, and /var is a symlink:

lrwxrwxrwx 1 root root 9 Nov 20 13:25 /var -> /data/var
lrwxrwxrwx 1 root root 9 Nov 20 23:41 /var/lock -> /run/lock
drwxr-xr-x 5 root root 4096 Nov 20 13:42 /data
drwxr-xr-x 12 root root 4096 Nov 21 01:44 /data/var
drwxr-xr-x 6 root root 4096 Dec 18 06:25 /data/var/log
drwxr-x--- 3 root adm 4096 Dec  8 06:25 /data/var/log/apache2/

Apache seems to have issues with this approach:

mktemp: failed to create directory via template '/var/lock/apache2.XXXXXXXXXX': No such file or directory

I solved that by changing /etc/apache2/envvars to refer to /run/lock directly, but the next error wasn't solved by changing APACHE_LOG_DIR in envvars:

(2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for main error log
(2)No such file or directory: AH02291: Cannot access directory '/var/log/apache2/' for error log of vhost defined at /etc/apache2/sites-enabled/site.conf:2
AH00014: Configuration check failed

How can I make this work?

已采纳解答

原帖链接 · Roger Dueck · CC BY-SA 4.0

The solution is to bind mount, not symlink, as recommended here, with reasoning against the symlink to /var given in point #7:

the hierarchy standard dictates that it must be a directory

In my case, switching from symlink to bind mount was accomplished with:

sudo -s
rm /var && mkdir -p /var && mount -o bind /data/var /var
cat >> /etc/fstab << END
/data/var /var none bind 0 0
END

and now apache starts without complaint.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-12-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。