• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

petehouston/laravel-deploy-on-shared-hosting: The simple guide to deploy Laravel ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

petehouston/laravel-deploy-on-shared-hosting

开源软件地址(OpenSource Url):

https://github.com/petehouston/laravel-deploy-on-shared-hosting

开源编程语言(OpenSource Language):


开源软件介绍(OpenSource Introduction):

How to deploy Laravel applications on shared hosting

API Documentation API Documentation API Documentation API Documentation

The simple guide to deploy Laravel and Lumen application on shared hosting.

For a quick version of the guide (many of you might already read about it), read my post on medium, "The simple guide to deploy Laravel 5 application on shared hosting"

Requirements

Before trying to deploy a Laravel application on a shared hosting, you need to make sure that the hosting services provide a fit requirement to Laravel. Basically, following items are required for Laravel 5.2:

  • PHP >= 5.5.9
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension

Well, it also depends on the Laravel version you want to try to install, checkout the appropriate version of Laravel server requirements documentation.

Next, you need to have the SSH access permission for your hosting account; otherwise, none of these will work.

Besides PHP and those required extensions, you might need some utilities to make deployment much easier.

I guess that's enough for good. Please refer to below sections to learn more about deployment.

Instruction

Let's get started by understanding how we should organize the Laravel application structure. At first, you will have this or similar directories and files in your account,

.bash_history
.bash_logout
.bash_profile
.bashrc
.cache
.cpanel
.htpasswds
logs
mail
public_ftp
public_html
.ssh
tmp
etc
www -> public_html
...

For the main account which tied with the main domain, the front-end code should stay in public_html or www. Since, we don't want to expose Laravel things (such as, .env, ...) to the outside world, we will hide them.

Create a new directory to store all the code, name it projects or whatever you want to.

$ mkdir projects
$ cd projects

Alright, from here, just issue a git command to grab the code,

$ git clone http://[GIT_SERVER]/awesome-app.git
$ cd awesome-app

Next step is to make the awesome-app/public directory to map with www directory, symbol link is a great help for this, but we need to backup public directory first.

$ mv public public_bak
$ ln -s ~/www public
$ cp -a public_bak/* public/
$ cp public_bak/.htaccess public/

Because we created the symbol link from www directory to make it become the virtual public in project, so we have to update the ~/www/index.php in order to replace paths with the new ones:

- require __DIR__.’/../bootstrap/autoload.php’;
+ require __DIR__.'/../projects/awesome-app/bootstrap/autoload.php';

- $app = require_once __DIR__.’/../bootstrap/app.php’;
+ $app = require_once __DIR__.'/../projects/awesome-app/bootstrap/app.php';

The updated file should be:

require __DIR__.'/../projects/awesome-app/bootstrap/autoload.php';

$app = require_once __DIR__.'/../projects/awesome-app/bootstrap/app.php';

The hard part is done, the rest is to do some basic Laravel setup. Allow write permission to storage directory is important,

$ chmod -R o+w storage

Edit your .env for proper configuration. Don't miss this!

Lastly, update the required packages for Laravel project using composer and add some necessary caches,

$ php composer install
$ php composer dumpautoload -o
$ php artisan config:cache
$ php artisan route:cache

Congratulation! You've successfully set up a Laravel application on a shared hosting service.

FAQs

1. How to acquire SSH access permission for my account?

Just contact your hosting support, they will need to confirm your identity and will permit your SSH access in no time.

2. Where is git? I can't find it.

git is often put under this place in CPanel hosting services, /usr/local/cpanel/3rdparty/bin/git. So you need to provide full path to git if you want to issue a git command; or, you can also create an alias for convenient use,

alias git="/usr/local/cpanel/3rdparty/bin/git"

3. How to get composer?

You can use FTP or SCP command to upload composer.phar to the host after downloading it locally. Or use wget and curl to get the file directly on host,

$ wget https://getcomposer.org/composer.phar

or

$ curl -sS https://getcomposer.org/installer | php — –filename=composer

4. Does this work with Lumen?

Well, Laravel and Lumen are like twins, so it applies the same with Lumen.

5. I try to run composer but it shows nothing. What is the problem?

You need to provide a proper PHP configuration to run composer, which means, you cannot execute composer directly on some hosting service providers. So to execute composer, you will need to issue this command,

$ php -c php.ini composer [COMMAND]

6. Where can I get the php.ini to load for composer?

You can copy the default PHP configuration file php.ini, which is often at /usr/local/lib/php.ini, or find it by this command,

$ php -i | grep "php.ini"

List of service providers tested and worked

The following shared hosting service providers have been tested and worked perfectly 100%.

Works on GeekStorage shared plan but I had to enable PHP 5.6 via .htaccess

AddHandler application/x-httpd-php56 .php

If you found any hosting providers that works, please tell me, I will update the list for others to know about them, too.

Still trouble?

If you still fail to deploy Laravel applications after following all above steps. Provide me your issue in details, I will help you out.

Contribution Guide

Free free to fork the project and submit a pull request.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap