Laravel Deployment on Shared Hosting with or without SSH
- Compress your Laravel Project and upload it to Root of your Shared Hosting
- Extract your project to root of your Shared Hosting
- Move all files in your
public
topublic_html
folder - open
server.php
in root of your server (Included in Laravel Project) , renamepublic
word topublic_html
before
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
after
if ($uri !== '/' && file_exists(__DIR__.'/public_html'.$uri)) {
return false;
}
require_once __DIR__.'/public_html/index.php';
- Open
app\Providers\AppServiceProvider.php
and add this following code intopublic function register()
// override path.public
$this->app->bind('path.public',function(){
return base_path('public_html');
});
- Do the following instruction on 'Without SSH'
- Make sure your
.env
was configured - Force
composer
to update
composer install
- Generate new key , then execute
php artisan key:generate
- You Supposed to have no problem use your
artisan
andcomposer
command
You could init your git in root of Shared Hosting and add this following .gitignore
to prevent unnecessary file push to your git repository
Happy Code Guys
Please don't hesitate for issuing something that doesn't work for you, I will really happy to help you