All Projects → petehouston → Laravel Deploy On Shared Hosting

petehouston / Laravel Deploy On Shared Hosting

The simple guide to deploy Laravel application to shared hosting services.

Labels

Projects that are alternatives of or similar to Laravel Deploy On Shared Hosting

Kldns
快乐二级域名分发系统
Stars: ✭ 277 (-3.82%)
Mutual labels:  laravel
Laravel Setting
Persistent settings package for Laravel
Stars: ✭ 278 (-3.47%)
Mutual labels:  laravel
Laravel Gymie
👨‍💻 Gym & Club Management System https://gymie.in
Stars: ✭ 285 (-1.04%)
Mutual labels:  laravel
Lightcms
LightCMS是一个基于Laravel开发的轻量级CMS系统,也可以作为一个通用的后台管理框架使用。
Stars: ✭ 279 (-3.12%)
Mutual labels:  laravel
Laravel Achievements
Achievements for Laravel 5.3+
Stars: ✭ 279 (-3.12%)
Mutual labels:  laravel
Resources I Like
📚💯 Collection of learning resources i like
Stars: ✭ 280 (-2.78%)
Mutual labels:  laravel
Laravel Image
Image manipulation library for Laravel 4 and 5 based on Imagine (https://github.com/avalanche123/Imagine) and inspired by Croppa for easy url based manipulation (with caching)
Stars: ✭ 276 (-4.17%)
Mutual labels:  laravel
Wookteam
WookTeam是一款轻量级的开源在线团队协作工具,提供各类文档协作工具、在线思维导图、在线流程图、项目管理、任务分发、即时IM,知识库管理等工具。
Stars: ✭ 287 (-0.35%)
Mutual labels:  laravel
Laravel Starter Kit
Laravel 7.0~ Starter Kit Powered by VueJS + Material Design(Vuetify)
Stars: ✭ 281 (-2.43%)
Mutual labels:  laravel
Laravel Sign In With Apple
Provide "Sign In With Apple" functionality to your Laravel app.
Stars: ✭ 283 (-1.74%)
Mutual labels:  laravel
Laravel Postal Code Validation
Worldwide postal code validation for Laravel and Lumen
Stars: ✭ 278 (-3.47%)
Mutual labels:  laravel
Laravel Dashboard
A beautiful dashboard for Laravel
Stars: ✭ 280 (-2.78%)
Mutual labels:  laravel
Tipask
Tipask是一款开放源码的PHP问答系统,基于Laravel框架开发,容易扩展,具有强大的负载能力和稳定性。
Stars: ✭ 282 (-2.08%)
Mutual labels:  laravel
Dnsrecords.io
A webapp to fetch dns records
Stars: ✭ 278 (-3.47%)
Mutual labels:  laravel
Stripe Laravel
Cartalyst Stripe package integration for Laravel.
Stars: ✭ 286 (-0.69%)
Mutual labels:  laravel
Themevel
Theme and asset management for laravel
Stars: ✭ 278 (-3.47%)
Mutual labels:  laravel
Laravel Job Status
Add ability to track Job progress, status and result dispatched to Queue.
Stars: ✭ 279 (-3.12%)
Mutual labels:  laravel
Laravel Websockets Demo
Demo application to use with the Laravel WebSockets package.
Stars: ✭ 286 (-0.69%)
Mutual labels:  laravel
Laravel Apidoc Generator
Laravel API Documentation Generator
Stars: ✭ 3,170 (+1000.69%)
Mutual labels:  laravel
Apilogger
Small laravel package for viewing api logs which can be used in debugging.
Stars: ✭ 285 (-1.04%)
Mutual labels:  laravel

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].