链接~/dir
到本地目录的正确方法是什么/path/dir
,以便查找的 PHP 服务器/path/dir/file.php
能够找到~/dir/file.php
?
在我的具体情况下,我在 Mac 上运行 XAMPP PHP 服务器时出现以下错误:
Warning: include_once(/Applications/XAMPP/xamppfiles/htdocs/tms/tms.php) [function.include-once]: failed to open stream: No such file or directory in /Users/dmitrizaitsev/Sites/newsite/index.php on line 2
Warning: include_once() [function.include]: Failed opening '/Applications/XAMPP/xamppfiles/htdocs/tms/tms.php' for inclusion (include_path='.:/Applications/XAMPP/xamppfiles/lib/php: /Applications/XAMPP/xamppfiles/lib/php/pear') in /Users/dmitrizaitsev/Sites/newsite/index.php on line 2
因此 PHP 正在寻找该文件:
/Applications/XAMPP/xamppfiles/htdocs/tms/tms.php
我正在尝试将其链接到我的本地目录
/Users/dmitrizaitsev/Sites/newsite/tms
...其中包含文件tms.php
。
我曾尝试
sudo ln -s ~/Sites/newsite/tms /Applications/XAMPP/xamppfiles/htdocs/
ls -lisa /Applications/XAMPP/xamppfiles/htdocs/tms
26232130 8 lrwxr-xr-x 1 root admin 38 26 Apr 16:30 /Applications/XAMPP/xamppfiles/htdocs/tms -> /Users/dmitrizaitsev/Sites/newsite/tms
但它似乎不适用于 PHP 并且没有列出文件:
|system| Dmitris-MacBook-Pro in /Applications/XAMPP/xamppfiles/htdocs
○ → ls -lisa /Applications/XAMPP/xamppfiles/htdocs/tms/
ls: /Applications/XAMPP/xamppfiles/htdocs/tms/: No such file or directory