Skip to content

Instantly share code, notes, and snippets.

@hamog
Last active September 10, 2019 13:38
Show Gist options
  • Save hamog/05e45d8c15666f4b3d392393485ec2df to your computer and use it in GitHub Desktop.
Save hamog/05e45d8c15666f4b3d392393485ec2df 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 !

@aliabbasi68
Copy link

Very Good Mr hamog :-)

@aeadedoyin
Copy link

Thanks!

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