简体   繁体   English

将Laravel 5项目上传到共享主机

[英]Uploading Laravel 5 Project to Shared Hosting

I want to deploy a Laravel 5 project to shared hosting from my localhost but I am facing so many problems. 我想将Laravel 5项目部署到本地主机上的共享主机,但是我面临很多问题。 I have uploaded all files in a subfolder of my shared hosting (PHP 5.5) and when I try http://domain.com/subfolder/public its showing me 500 error. 我已将所有文件上传到共享托管(PHP 5.5)的子文件夹中,当我尝试http://domain.com/subfolder/public时,它向我显示500错误。 I check the laravel.log but found nothing, set the storage/ to 777 but still no changed (showing last error from localhost). 我检查了laravel.log但未找到任何内容,将storage/设置为777,但仍未更改(显示来自localhost的最后一个错误)。

I also check .htaccess and it seems good. 我也检查.htaccess ,它似乎很好。 I search a lot and try so many thing but still facing same problem. 我进行了很多搜索,尝试了很多事情,但仍然面临着同样的问题。

Now, my shared hosting give access of SSH so I have installed a new Laravel project. 现在,我的共享主机可以访问SSH,因此我安装了一个新的Laravel项目。 Then copy my edited and added file except vendor from my localhost to Hosting. 然后将除供应商以外的其他已编辑和添加的文件从本地主机复制到主机。 Then I update the composer and dump-autoload, Now my application is working file. 然后,我更新了作曲家和dump-autoload,现在我的应用程序正在工作文件中。

But I am not sure about the process I did. 但是我不确定我所做的过程。 Is it the right way (I don't think so)? 这是正确的方法吗(我不这么认为)? Please let me know what was the problem of directly uploaded file and is there any problem if I use second system for my production app. 请让我知道直接上传文件的问题是什么,如果我将第二个系统用于我的生产应用程序,会出现任何问题。

There are chances that your route cache is messed up. 您的路由缓存很可能混乱了。 It is safe to artisan route:clear , artisan cache:clear , and artisan view:clear before uploading your files to ensure that no compiled script left - which usually tied to specific path. 在上传文件之前,确保artisan route:clearartisan cache:clearartisan view:clear是安全的,以确保没有剩余的已编译脚本-通常与特定路径绑定。

But it is unclear, could you share your stacktrace for your error (and if possible share where your .htaccess file and it's content)? 但是还不清楚,您是否可以为错误共享堆栈跟踪信息(如果可能,还可以共享.htaccess文件及其所在的位置)? sorry i can't comment, need higher point. 对不起,我不能发表评论,需要更高的分数。 However, by looking at your statement that it works by moving your files (controller, views, public, etc) but not the entire project, i believe clearing caches is the best to try. 但是,通过查看您声明的文件是否可以移动文件(控制器,视图,公共文件等)而不是整个项目,我相信清除缓存是最好的尝试。

As for the deployment of laravel project, there are methods suggested in laravel.io . 至于laravel项目的部署,也有建议的方法laravel.io It is not a good idea to expose your entire laravel files in public folder. 在公共文件夹中公开整个Laravel文件不是一个好主意。 Nevertheless, there are many ways to deploy it. 但是,有很多方法可以部署它。

I know it's a little late but you need to either: 1. Make laravel's public folder the root folder of your domain or 2. Make a sub-domain and point the root folder to your projects public folder. 我知道已经晚了,但是您需要:1.将laravel的公用文件夹设为您域的根文件夹,或者2.制作一个子域,然后将根文件夹指向项目的公用文件夹。 The disadvantage with this is that your sessions cannot be connected directly to your main domain's sessions. 这样做的缺点是您的会话无法直接连接到主域的会话。

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

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