当前位置: 首页 > 知识库问答 >
问题:

Laravel 5共享主机部署问题

慕容齐智
2023-03-14

我正在尝试在共享主机上部署Laravel5.2。

我在public_html文件夹(/../public_html或/home/username)之上安装了laravel core应用程序文件夹。

我提取了laravel核心公用文件夹(public)中的文件,并指向索引。php文件到laravel core app文件夹的根目录(/../laravel app/bootstrap/autoload.php和/./laravel app/bootstrap/app.php)。

该网站的主页正在运行,但是页面链接返回404,并且没有任何css或js。

有没有办法解决这个问题?

注意事项:我使用的是php 5.6版,我将laravel app/storage中的文件权限更改为777,我删除了该文件。公共html文件夹服务器中的htaccess fil是apache

共有1个答案

顾喜
2023-03-14

伙计,按照这个教程,我试过了,效果很好!

https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.5lywcjmnn

顺便说一句,你甚至不需要这句话后面的最后一部分

如果您的服务器上还没有安装作曲家,那么您可以轻松地将其抓取到项目目录。

在我的例子中,我做了如下操作:将laravel项目作为lara文件夹放置在public_html之外

然后我就有了这样一个途径:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

在public_html我有。

RewriteEngine On
RewriteCond %{REQUEST_URI} !^awesome
RewriteRule ^(.*)$ awesome/$1 [L]

其中真棒是包含hacess(向下列出)和index.php,收藏夹和robots.txt的目录:

<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>

最后的变化是index.php

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylorotwell@gmail.com>
 */

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels nice to relax.
|
*/

/* die(__DIR__);  /home/{YOURHOST}/public_html/awesome */
require __DIR__.'/../../lara/bootstrap/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../../lara/bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);
 类似资料:
  • 我部署我laravel 5.4项目在共享主机上使用子域我安装了作曲家,改变了路径的index.php,供应商路径,DB主机,用户名等。 我得到以下错误 致命错误:未捕获意外值异常:在"/存储/日志"中没有现有目录,并且无法构建:在 /vendor/monolog/monolog/src/Monolog/Handler/StreamH中拒绝权限andler.php:171 我尝试了以下命令:php

  • 我部署了一个laravel应用程序到共享主机(host inger)。除了没有显示的图像,一切都很好。 我已经创建了一个符号链接的存储文件夹与我的public_html文件夹。上传的文件进入公共文件夹,但当我链接图像时,它们仍然不显示。 由于无法访问公用文件夹,我已创建指向公用html的符号链接。我需要你的帮助 我需要图像显示在浏览器上

  • PHP 非常流行,很少有服务器没有安装 PHP 的,因而有很多共享主机,不过需要注意服务器上的 PHP 是否是最新 版本。共享主机允许多个开发者把自己的网站部署在同一台服务器上面,这样的好处是费用非常便宜,坏处是你不知道将和哪些 网站共享主机,因此需要仔细考虑机器负载和安全问题。如果项目预算允许的话,避免使用共享主机是上策。

  • 我在共享主机上部署了一个Laravel 5.5应用程序,但在上传/查看图像时遇到问题。 localhost一切正常,但是当我上传到网上时,我无法访问存储图像的目录。 这里是存储我的图像的地方 它将图像存储在: public_html/nbd/公共/项目/307/my-image.png 这里还有我的图像设置: 我的应用程序位于 public_html/nbd/系统 ...因为我必须将公用文件夹从系

  • 我遇到的问题,当部署laravel到共享托管css和js文件没有找到,我上传laravel文件到public_html和改变server.phpindex.php然后移动. htaccess这是在公共public_html文件夹。我使用这个方法来删除url中的公共文件夹。

  • 我一直在论坛和网上寻找关于如何使用plesk将Laravel 5部署到godaddy windows主机服务器上的指南,但我找不到太多信息。我希望这里有人能帮我。以下是我所做的: > 首先,我下载了一个新的laravel安装并将其解压缩到根目录。 然后,我将整个公共文件夹从laravel文件夹(最近从提取中创建)移动到http pdocs文件夹。 之后,我编辑了位于公共文件夹中的index.php