laravel 如何在bluehost上解聚/上传laravel项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39475265/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 14:27:21  来源:igfitidea点击:

how to depoly/upload laravel project on bluehost

phplaraveldeploymentshared-hosting

提问by Abdulelah.k

i have laravel project that is ready to deploy,

我有准备部署的 Laravel 项目,

i need to deploy it on blue host,

我需要将它部署在蓝色主机上,

i searched so many times about this but could not find clear answer,

我搜索了很多次,但找不到明确的答案,

so could you please guide me to deploy this laravel project ?

所以你能指导我部署这个 Laravel 项目吗?

回答by Naresh Kumar P

After trying so many methods, I have managed to deploy a Laravel 5.1 application to a shared hosting. Hope this will save you some time. The following steps are tried and tested in 1and1 dedicated hosting server.

在尝试了这么多方法之后,我设法将 Laravel 5.1 应用程序部署到共享主机。希望这会为您节省一些时间。以下步骤在 1and1 专用托管服务器中进行了尝试和测试。

You should have SSH access to the server to install composer and some artisan commands.

您应该可以通过 SSH 访问服务器以安装 composer 和一些 artisan 命令。

Installing composer:

安装作曲家:

Connect to your server via ssh.

通过 ssh 连接到您的服务器。

1and1 instances have multiple versions of php installed. Laravel needs at least php version 5.5.29. So you can check the available php versions. php5.5 should be good enough for rest of the steps.

1and1 实例安装了多个版本的 php。Laravel 至少需要 php 5.5.29 版本。所以你可以检查可用的php版本。php5.5 应该足以完成其余步骤。

$ ls /usr/bin/ | grep php
$ php5.5 -v
PHP 5.5.33 (cgi-fcgi) (built: Mar 8 2016 15:42:28)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

Go to the desired directory (Normally the website's root directory). Download the composer installer.

转到所需的目录(通常是网站的根目录)。下载 Composer 安装程序。

$ wget https://getcomposer.org/installer
$ php5.5 installer

Now you can see a file composer.phar downloaded to the current directory. This should be used for all composer activities.

现在您可以看到下载到当前目录的文件 composer.phar。这应该用于所有作曲家活动。

Upload the source code (or clone from repository) to this directory. (Don't forget to modify your .env file) Edit the artisan file and scripts part of composer.json file to change all references of php to php5.5

将源代码(或从存储库克隆)上传到此目录。(不要忘记修改你的 .env 文件)编辑 composer.json 文件的 artisan 文件和脚本部分,将 php 的所有引用更改为 php5.5

Run the below command to perform composer install.

运行以下命令来执行 composer install。

$ php5.5 composer.phar install

Run the below command to perform db migrate.

运行以下命令来执行数据库迁移。

$ php5.5 artisan migrate

Replace all the lines in the /public/.htaccess with the below:

将 /public/.htaccess 中的所有行替换为以下内容:

RewriteBase /public/

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

At this point your laravel application should be up and running on http://yourdomain.com/public. You can modify your website root to point to /public to remove public from the URL.

此时,您的 Laravel 应用程序应该在http://yourdomain.com/public上启动并运行。您可以修改您的网站根目录以指向 /public 以从 URL 中删除 public。