Skip to content

Instantly share code, notes, and snippets.

@joeymetal
Forked from hamog/laravel_deploy.md
Created March 6, 2019 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joeymetal/e3f8c399265fe2a6c4ffdcf2df8bc9a7 to your computer and use it in GitHub Desktop.
Save joeymetal/e3f8c399265fe2a6c4ffdcf2df8bc9a7 to your computer and use it in GitHub Desktop.
Deploy laravel 5 application on shared hosting.

Deploy Laravel 5 application on shared hosting

Server Requirements (Laravel 5.4)

  • PHP >= 5.6.4
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension

How to deploy

1- Create a new directory alongside public_html/ directory (public_html directory in some hosts maybe different name like www).

2- Copy all your application source code except public directory in new directory (for example directory name is project).

3- Copy all contents inside the public/ directory to public_html/ directory.

4- Modify public_html/index.php as follows:

require __DIR__.'/../project/bootstrap/autoload.php';

$app = require_once __DIR__.'/../project/bootstrap/app.php';

$app->bind('path.public', function() {
    return __DIR__;
});

5- Set 777 permissions for project/storage and project/bootstrap/cache directories.

6- Modify .env file according to your host information such as database, mail, cache, ...

APP_ENV=production
APP_KEY=base64:q+MEY0Z5Uf/N4icj4oDEmXtZPD6jOzJu4++BUToOz8U=
APP_DEBUG=false
APP_LOG_LEVEL=debug
APP_URL=http://your-domain.com

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=your-database-name
DB_USERNAME=your-user-name
DB_PASSWORD=your-password

7- Open your-domain.com in browser And you're good to go !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment