【发布时间】:2016-09-14 19:49:26
【问题描述】:
简介
我正在努力将 Laravel 项目部署到域子文件夹...这是完整的“故事”:
我的老师控制着机器:http://ilp.fe.up.pt/
他为我创建了一个名为 mitocondrias 的用户,因此我可以通过 ssh 使用它,例如:ssh mitocondrias@ilp.fe.up.pt
他还将通常的public_html 文件夹设置为仅称为html。
所以,总而言之,如果我在/home/mitocondrias/html/ 创建一个简单的hello world index.html,我可以在http://ilp.fe.up.pt/mitocondrias/ 成功看到它
我做了什么
现在,关于 Laravel 部署,这是我所做的:
我将名为 CoExpr 的 Laravel 项目克隆到我的用户主页:/home/mitocondrias/coexpr
我删除了html 文件夹并使用以下命令创建了一个symlink 到/home/mitocondrias/coexpr/public,名为html:
mitocondrias@ilp:~$ ln -s ~/coexpr/public/ html
所以,这是最终的树结构:
ilp.fe.up.pt/ (the root of my teacher web hosting)
|
|-- mitocondrias/ (my user home, aka /home/mitocondrias)
| |
| |-- coexpr/ (the Laravel project)
| | |
| | |-- [...]
| | |-- public/
| | |-- [...]
| |
| |-- html/ (this is actually not a folder,
| | but a symlink to /home/mitocondrias/coexpr/public/)
我还运行了以下命令来设置正确的 Laravel 权限:
chmod -R 755 coexpr/chmod -R o+w storage
问题
在这一切之后,我可以在http://ilp.fe.up.pt/mitocondrias/ 上成功看到登录页面(如果我使用php artisan serve 为应用程序提供服务,则相当于localhost:8000)
但是当我尝试使用其他路由时,例如:http://ilp.fe.up.pt/mitocondrias/explorer(相当于localhost:8000/explorer)我得到:
404 Not Found
The requested URL /home/mitocondrias/html/index.php was not found on this server.
我做错了什么..?
额外信息
如果这是相关的,/home/mitocondrias/coexpr/public/ 中的 .htaccess 是在使用 composer 创建 Laravel 项目时生成的 - 我没有碰它:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
因为symlink,这也是.htaccess/home/mitocondrias/html/。
结束
所以,就是这样...... Aff,这是一个很长的帖子......提前谢谢!
【问题讨论】:
-
也许最简单的方法是让你的老师使用
public作为网络根而不是html,然后将所有内容上移一级,去掉coexpr/和符号链接。这可能吗? -
啊,也许你那里有一个重复的斜线。
ln -s ~/coexpr/public/ html- 看起来你可能只需要ln -s ~/coexpr/public html -
@JanPapenbrock 我认为公开后的斜线是无所谓的
-
是的,我也这么认为。查看下面我的答案以获得最可能的解决方案。
-
@JanPapenbrock 我正在等待我的老师应用更改(我不在 sudoers 列表中)。有任何消息我会尽快回复您。