• Stars
    star
    309
  • Rank 135,306 (Top 3 %)
  • Language
  • Created almost 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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.

More Repositories

1

vue-ui-framework

My personal collection of Vue UI framework
241
star
2

laravel-docs-vn

The Vietnamese translation of the Official Laravel Documentation
129
star
3

flutter-emoji

👉 A light-weight Emoji 📦 for Flutter and Dart-based applications with all up-to-date emojis 😄. Made from 💯% ☕ with ❤️!
Dart
68
star
4

laravel-tinymce-simple-imageupload

Simple image upload for TinyMCE in Laravel.
Blade
67
star
5

react-ui-framework

My personal collection of React UI Framework.
60
star
6

awesome-os-dev

The collection of useful resources for OS development
46
star
7

flutter-tips

My collection of Flutter development tips
Dart
37
star
8

auth-laravel-angular-jwt-satellizer

This is the demo source code that demonstrate a complete API service for authentication that uses Laravel, AngularJS, JWT and Satellizer.
PHP
27
star
9

awesome-gamedev-series

My personal collection of complete game development series.
23
star
10

bulma-landing-page-template

Landing page template using Bulma CSS framework
CSS
17
star
11

udemy-crawler

Crawling Udemy course info and save into JSON format.
JavaScript
17
star
12

react-makes-you-sad

Here’s a flowchart to make you happy again!
14
star
13

learn-dart

Learn Dart programming with me.
Dart
14
star
14

thuat-ngu-laravel

Tổng hợp các thuật ngữ sử dụng trong Laravel framework.
13
star
15

inspect-osx-startup-items

Find all the possible locations for OS X startup items.
10
star
16

docker-alpine-php

A very small Docker image to bootstrap your PHP development
Shell
10
star
17

simple-newsletter

A very simple newsletter application using NodeJS, ExpressJS, MongoDB and AngularJS.
JavaScript
10
star
18

ionic-anything-app

The demo Ionic app that uses ngStorage.
JavaScript
9
star
19

flutter-simple-message-app-ui

Flutter Practice: Simple message app UI
Dart
8
star
20

sketch-guides

Just another Guide plugin for Sketch
7
star
21

geonames-db

Create your own geo database.
Python
6
star
22

hadoop-wordcount

Word Count using Apache Hadoop 3+
Java
6
star
23

flutter-image-asset

Flutter tutorials - load image from assets
Dart
5
star
24

gitbook-plugin-google-adsense

Inject Google Adsense to your Gitbook.
JavaScript
5
star
25

dart-json-server

Launch JSON server for web and mobile apps development from CLI without complicated backend setup for Dart and Flutter development.
Dart
4
star
26

learning-flutter-dashboard

A dashboard app built using Flutter
Dart
4
star
27

xin-artisan

The "xin" command for Laravel artisan.
PHP
4
star
28

demo-protobuf-js

Demo usage of Protobuf in Javascript
JavaScript
4
star
29

react-videv

Directory of Vietnamese React Developers.
JavaScript
4
star
30

pretests-coding

Java
3
star
31

flutter-quick-wireframe-01

Just part of work in progress with Flutter app. Nothing fancy.
Dart
3
star
32

create-dart-lib

Utility to generate template to develop Dart library.
Dart
3
star
33

netty-echo-server

An Echo server built using Netty
Java
3
star
34

docker-alpine-php-composer

A very small Docker image to bootstrap your PHP development with Composer support.
Shell
3
star
35

nhieu-php

Simple Vietnamese pluralization.
PHP
2
star
36

slack-simple-webhooks

Simple Slack webhooks API.
PHP
2
star
37

physical-dimension-breakpoints

The common media breakpoints for physical dimension of smart devices.
CSS
2
star
38

tinymce-codesample-prism

CSS
2
star
39

demo-java-gradle

Using Gradle build system to develop a perfect Java application with minimum effort.
Java
2
star
40

demo-react-meets-cssx

Using React with CSSX
JavaScript
2
star
41

javafx-bouncing-ball

Bouncing ball in JavaFX
Java
2
star
42

laptrinh-io-html-template

The HTML template for the web
CSS
2
star
43

php-sample-code

PHP sample code for coding tutorials and tips at blog.petehouston.com
PHP
2
star
44

hotjs-cli

CLI for HotJS latest news and articles.
JavaScript
2
star
45

tinymce-bootstrap-media

A TinyMCE plugin to insert responsive embedded media source.
JavaScript
2
star
46

laravel-many-to-many-relationship-demo

Demo for Laravel Eloquent many-to-many relationship
PHP
2
star
47

angular-ui-framework

My collection of UI framework based on Angular
1
star
48

go-randomuser

A Go library to generate random user information.
Go
1
star
49

mean-jobhunt

A job listing directory built with MEAN stack.
TypeScript
1
star
50

docker-alpine-ruby

A very small Docker image to bootstrap your Ruby code.
1
star
51

nginx-conf-files

Some useful nginx conf files for sites
1
star
52

go-osx-version

Get OS X version information
Go
1
star
53

drupal8-local-dev

Get Drupal 8 local development up and running without manual and complicated setup on dev machine.
PHP
1
star
54

css-grid-chessboard

Demo on using CSS Grid layout to draw a chess board
HTML
1
star
55

app-icons

My directory of common app icons
1
star
56

go-kubernetes

Setup a Go app with Kubernetes locally.
Go
1
star
57

201-Animations

Explore Animations with Flutter
Dart
1
star
58

lazy-scripts

I'm lazy so I script
JavaScript
1
star
59

flutter-circle-image

Create circle image for UI component
Dart
1
star
60

oooops-i-cooked-choo

The failure choo learning book
1
star
61

ionic-starter-blank-by-features

A blank Ionic starter project which supports by-feature organization
JavaScript
1
star
62

red-wine-quality-bayes

Predict the red wine quality using Bayes Classification
Jupyter Notebook
1
star
63

golang-sample-code

Go sample code for the blog, https://blog.petehouston.com
Go
1
star
64

how-the-fuck-is-this-code-possible

Funny questions and strange answers for some WTF coding.
1
star
65

react-native-simple-map-car-booking-app

JavaScript
1
star
66

choo-counter

A counter app using choo framework
JavaScript
1
star
67

github-actions-query-branch-name

Get pure Git branch name
JavaScript
1
star
68

docker-alpine-core

A really small Docker images with base tools that every developers need to work with.
1
star
69

pokepoki

Just a Pokemon project for fun and profit.
JavaScript
1
star
70

mshot-cli

CLI to take screenshots for multiple website at one using Puppeteer.
JavaScript
1
star
71

algorithm-notes

TIL something from algorithms
1
star
72

the-only-bootstrap-page

The source code for "The Only Bootstrap Page"
HTML
1
star
73

dotfiles

My personal dot files
Vim Script
1
star
74

barel

The barebone template to bootstrap a Laravel project.
PHP
1
star
75

laravel-development-checklists

Personal checklist for Laravel development
1
star
76

something-mongo-test

JavaScript
1
star
77

jpa-template

Template for Java JPA using Hibernate with Maven configuration
Java
1
star
78

php-tips

My collection of PHP coding tips
PHP
1
star
79

angular-twitter-practice

Demo for filter pipe using Angular
TypeScript
1
star
80

docker-magento-utils

Docker utils image to use for Magento 2.
Dockerfile
1
star
81

node-proshot

Handy tool to capture website screenshots using Puppeteer.
JavaScript
1
star
82

color-converter

This package helps to convert color between Hex and RGB.
PHP
1
star
83

docker-mysql-client

Docker build for MySQL and MariaDB client
Dockerfile
1
star
84

angular-countdown-directive-sample

Angular countdown directive sample. A practice on Angular framework.
TypeScript
1
star
85

laravel-9-tutorials-code

Laravel 9 tutorials code for blog.petehouston.com
PHP
1
star
86

translation-model

The update Language model to fix the default Waavi Language model compatibility issue in Laravel 4.2.
PHP
1
star
87

laravel-tips

My collection of Laravel development tips
1
star
88

css-grid-tiktaktoe-board

Demo on using CSS Grid Layout to design a Tik-Tak-Toe board
HTML
1
star