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

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

问题描述

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

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.

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

This is my web server's structure ->

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

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

这是我的Laravel项目的目录:

This is my Laravel project's directory :

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

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:

最简单的方法是将所有文件上传到您所在的目录(即cPanel用户主目录)中,然后将public的内容放入public_html中.这样,您的目录结构将是这样的(有点混乱,但它可以工作):

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

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

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

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

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天全站免登陆