在我的主目录中,我有一个laravel项目文件夹:
/home
/user
/project
/public <--------.
index.php |
/bootstrap |
autoload.php |
/config |
/public |
/src |
/http |
/project (softlink to here)
在project/public/index.php
我有这个:
require __DIR__.'/../bootstrap/autoload.php';
我将我的apache公用文件夹软链接到用户目录中的公用文件夹:
$ ln -s /home/user/project/public /srv/http/project
所以我应该可以打开localhost/project
。但我得到500内部服务器错误。这是来自apache的相关日志:
$ cat /var/log/httpd/error_log
[Tue Jun 02 2015] [:error] PHP Warning: require(/home/user/project/config/public/../bootstrap/autoload.php): failed to open stream: No such file or directory in /home/user/project/config/public/index.php on line 21, referer: http://localhost/project/
[Tue Jun 02 2015] [:error] PHP Fatal error: require(): Failed opening required '/home/user/project/config/public/../bootstrap/autoload.php' (include_path='/home/user/project/vendor/phpunit/php-text-template:/home/user/project/vendor/phpunit/php-timer:.:/usr/share/pear') in /home/user/project/config/public/index.php on line 21, referer: http://localhost/project/
日志表明服务器正在寻找/home/user/project/config/bootstrap/autoload.php
。为什么呢?我没有链接到/home/user/project/config/public
。我不知道这是apache,php,链接还是文件系统的问题。
答案 0 :(得分:1)
/home
/user
/project
/public <--------.
index.php |
/bootstrap |
autoload.php |
/config |
/public |
/src |
/http |
/project (softlink to here)
因此,随着符号链接扁平,您的docroot看起来像:
/src
/http
/project
index.php
就您的申请而言, ../bootstrap
不存在。
将符号链接向上移动一级:
$ ln -s /home/user/project /srv/http/project