简体   繁体   English

如何在子域上部署Laravel 5

[英]How to deploy Laravel 5 on a subdomain

I have been using Laravel for quite a while but only recently have the need to deploy an app on a subdomain and I'm having some trouble. 我已经使用Laravel了很长一段时间,但是直到最近才需要在子域上部署应用程序,并且遇到了一些麻烦。 Everything works as it should if it's not deployed under a subdomain. 如果未部署在子域下,则一切正常。

So I have: domain.com (main site) and subdomain.domain.com (app) 所以我有:domain.com(主站点)和subdomain.domain.com(应用程序)

When I pull up the subdomain in the browser the index page loads fine(subdomain.domain.com), but when I try to access the login view(subdomain.domain.com/auth/login) - or any other view other than index - I get the following error: 当我在浏览器中拉起子域时,索引页面会很好地加载(subdomain.domain.com),但是当我尝试访问登录视图(subdomain.domain.com/auth/login)时-或除索引以外的任何其他视图-我收到以下错误:

ErrorException in Connector.php line 47: SQLSTATE[HY000] [2002] No such file or directory (View: /var/www/vhosts/domain.com/subdomain/resources/views/app.blade.php) (View: /var/www/vhosts/domain.com/subdomain/resources/views/app.blade.php) Connector.php第47行中的ErrorException:SQLSTATE [HY000] [2002]没有这样的文件或目录(查看:/var/www/vhosts/domain.com/subdomain/resources/views/app.blade.php)(查看:/无功/网络/虚拟主机/ domain.com /子/资源/视图/ app.blade.php)

So, it appears Laravel is looking for resources in the wrong directory, but I don't know where to configure the app to look for them in the correct location. 因此,Laravel似乎在错误的目录中寻找资源,但是我不知道在哪里配置应用程序以在正确的位置寻找它们。

It's on a GoDaddy VPS. 在GoDaddy VPS上。 I have update config/app.php url to: http://subdomain.domain.com 我将config / app.php网址更新为: http ://subdomain.domain.com

I setup the subdomain via Plesk and the root points to the public folder under the subdomain. 我通过Plesk设置了子域,其根指向该子域下的公用文件夹。

I have tried wrapping my routes in Route::group(['domain' => 'subdomain.domain.com']....but that didn't help. 我曾尝试将我的路线包装在Route :: group(['domain'=>'subdomain.domain.com'] ....中,但这无济于事。

Can anyone please point me in the right direction here? 有人可以在这里指出正确的方向吗? Thanks. 谢谢。

I had dismissed the possibility of it being a db issue previously because I knew the credentials were correct and I had deployed in on the top-level for testing and it worked. 我之前已经排除了它可能是数据库问题的可能性,因为我知道凭据是正确的,并且已经部署在顶层进行测试并且可以正常工作。 I just checked my .env file again and everything is correct, but I added port :3306 to localhost and now it's working! 我只是再次检查了我的.env文件,但一切都正确,但是我将端口:3306添加到了localhost,现在可以正常工作了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM