遍历符号链接目录时无法打开文件

遍历符号链接目录时无法打开文件

Nginx 无法启动,出现以下错误:

nginx: [emerg] ModSecurityConfig in /usr/local/server/nginx/conf/nginx.conf:133: Cannot open config file: /usr/local/server/nginx/conf/../base/base.conf

配置在块中指定如下http{}

ModSecurityConfig ../base/base.conf;

此外,conf 目录是文件夹的符号链接/vagrant/conf/

vagrant@node3:/usr/local/server/nginx$ ls -laht
total 68K
drwxr-xr-x 16 serv    serv    4.0K Oct  7 02:12 .
lrwxrwxrwx  1 root    root      14 Oct  7 02:12 conf -> /vagrant/conf/
drwxr-xr-x  3 root    root    4.0K Oct  6 09:17 logs
drwxr-xr-x  2 serv    serv    4.0K Oct  6 09:17 sbin
drwxr-xr-x  2 serv    serv    4.0K Apr 12 09:24 base <<-- the base folder is here

这是另一个有趣的行为,我相信与 nginx 无法读取所需文件有关。

vagrant@node3:/usr/local/server/nginx/base$ head -n1 /usr/local/server/nginx/conf/../base/base.conf
head: cannot open ‘/usr/local/server/nginx/conf/../base/base.conf’ for reading: No such file or directory
vagrant@node3:/usr/local/server/nginx/base$ cd /usr/local/server/nginx/conf/../base/
vagrant@node3:/usr/local/server/nginx/base$ head -n1 base.conf
### BLAH

答案1

一定会喜欢符号链接。

当你使用它们时,它只是一个新目录结构的快捷方式,当然 /vagrant/base (/vagrant/conf/../base) 不存在。

cd /vagrant/conf
ln -s /usr/local/server/nginx/base base

将您的 base.conf 文件位置更改为“base/base.conf”减去引号。

相关内容