将 Laravel 项目上传到 Web 服务器 [英] Uploading Laravel Project onto Web Server

查看:28
本文介绍了将 Laravel 项目上传到 Web 服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将我的 Laravel 项目上传到我的网络服务器,但我过去的两次尝试都没有成功.我相信我没有将文件上传到正确的位置.

这是我的 Web 服务器的结构 ->

我说我需要将所有 Laravel 文件上传到 public_html 是否正确?

这是我的 Laravel 项目目录:

我现在已将所有文件添加到根文件夹中,并将 public 添加到 public_html,但是我的路由似乎都不起作用.(它们在本地主机上完美运行).一切都会抛出 404

解决方案

不,但您有几个选择:

最简单的方法是将您拥有的所有文件上传到您所在的目录(即 cPanel 用户主目录),并将 public 的内容放入 public_html.这样你的目录结构就会是这样的(有点乱,但它有效):

<预><代码>/.作曲家/.cpanel/...app/<- 你的 Laravel 应用目录等等/bootstrap/<- 你的 Laravel 引导目录邮件/public_html/<- 你的 Laravel 公共目录小贩/artisan <- 你项目的根文件

您可能还需要编辑 bootstrap/paths.php 以指向正确的公共目录.

另一种解决方案,如果您不喜欢将所有这些文件都放在那个根"目录中,那么将它们放在它们自己的目录(可能是laravel")中,该目录仍然在根目录中,然后编辑路径正常工作.不过,您仍然需要将 public 的内容放在 public_html 中,这次编辑您的 public_html/index.php 以正确引导应用程序.通过这种方式,您的文件夹结构会更加整洁(尽管由于更多地弄乱了框架的设计结构,路径可能会令人头疼):

<预><代码>/.作曲家/.cpanel/...等等/laravel/<- 包含除 public 之外的所有项目文件的目录应用程序/引导程序/小贩/工匠邮件/public_html/<- 你的 Laravel 公共目录

I am trying to upload my Laravel project onto my web server, but my past two attempts have been unsuccessful. I believe I am not uploading the files to the right location.

This is my web server's structure ->

Am I correct to say that I need to upload ALL of my laravel files into public_html?

This is my Laravel project's directory :

EDIT : I have now added all the files onto the root folder, and public into public_html, however none of my routes seem to work. (They work perfectly on localhost). Everything throws a 404

解决方案

No, but you have a couple of options:

The easiest is to upload all the files you have into that directory you're in (i.e. the cPanel user home directory), and put the contents of public into public_html. That way your directory structure will be something like this (slightly messy but it works):

/
    .composer/
    .cpanel/
    ...
    app/                 <- your laravel app directory
    etc/
    bootstrap/           <- your laravel bootstrap directory
    mail/
    public_html/         <- your laravel public directory
    vendor/
    artisan              <- your project's root files

You may also need to edit bootstrap/paths.php to point at the correct public directory.

The other solution, if you don't like having all these files in that 'root' directory would be to put them in their own directory (maybe 'laravel') that's still in the root directory and then edit the paths to work correctly. You'll still need to put the contents of public in public_html, though, and this time edit your public_html/index.php to correctly bootstrap the application. Your folder structure will be a lot tidier this way (though there could be some headaches with paths due to messing with the framework's designed structure more):

/
    .composer/
    .cpanel/
    ...
    etc/
    laravel/      <- a directory containing all your project files except public
        app/
        bootstrap/
        vendor/
        artisan
    mail/
    public_html/  <- your laravel public directory

这篇关于将 Laravel 项目上传到 Web 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆