简体   繁体   English

准备 Laravel 应用程序以在共享托管平台上托管

[英]preparing laravel app for hosting on a shared hosting platform

I am trying to deploy an incomplete laravel app to a shared hosting (to give a client a feel of the project).我正在尝试将不完整的 Laravel 应用程序部署到共享主机(让客户了解该项目)。 However, the directory structure of the shared hosting is quite different from what I developed locally - the presence of the public_html folder.但是,共享主机的目录结构和我在本地开发的有很大的不同——public_html文件夹的存在。 My css and js are located in the public folder.I have also linked my css file as such : <link rel="stylesheet" href="/css/style.css"> which works perfectly locally.我的 css 和 js 位于公共文件夹中。我还链接了我的 css 文件: <link rel="stylesheet" href="/css/style.css">在本地完美运行。 But when deploying to the shared hosting <link rel="stylesheet" href="/css/style.css"> will not work as it does not point to the public folder.但是当部署到共享主机时<link rel="stylesheet" href="/css/style.css">将不起作用,因为它不指向公共文件夹。 I intend to place the index.php file and .htaccess in the root folder (public_html) and change require __DIR__.'/../vendor/autoload.php';我打算将 index.php 文件和 .htaccess 放在根文件夹(public_html)中并更改require __DIR__.'/../vendor/autoload.php'; to require __DIR__.'/vendor/autoload.php'; require __DIR__.'/vendor/autoload.php'; also change $app = require_once __DIR__.'/../bootstrap/app.php';也改变$app = require_once __DIR__.'/../bootstrap/app.php'; to $app = require_once __DIR__.'/bootstrap/app.php';$app = require_once __DIR__.'/bootstrap/app.php'; . .

my question is how do I make asset('public/css/style.css') work locally so as to not make much changes when deploying to a shared hosting, as asset('public/css/style.css') does not work on my local environment?我的问题是如何让asset('public/css/style.css')在本地工作,以便在部署到共享主机时不会进行太多更改,因为asset('public/css/style.css')不会在我的本地环境中工作?

Note: <link rel="stylesheet" href="/css/style.css"> will not work on the shared hosting because I want to keep the css files in the public folder and not in the root directory (public_html).注意: <link rel="stylesheet" href="/css/style.css">在共享主机上不起作用,因为我想将 css 文件保存在公共文件夹中,而不是在根目录 (public_html) 中。

try this when you link CSS, js files当你链接 CSS、js 文件时试试这个

*If your index.php file is inside the public folder *如果您的 index.php 文件在 public 文件夹中

"{{URL('/css/style.css')}}" "{{URL('/css/style.css')}}"

  • If your index.php file is inside the root folder如果您的 index.php 文件在根文件夹内

"{{URL('public/css/style.css')}}" "{{URL('public/css/style.css')}}"

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

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