DEV Community

Cover image for Deploying Laravel8 app on shared-hosting (Hostinger)🌎

Deploying Laravel8 app on shared-hosting (Hostinger)🌎

Pushpak Chhajed on April 30, 2020

Hi, everyone! In this article, I’ll try to explain how you can deploy your laravel application on shared hosting. I’ll use hostinger.com. It is w...
Collapse
 
felix2056 profile image
Info Comment hidden by post author - thread only accessible via permalink

There's no way am complicating something so basic. What if you have the website working locally in a public folder rather than public_html and then you have to make changes to your local branch and re-deploy to git? You'll face errors when your local branch is not in sync with your remote branch.

The best way to do is:

  1. create a new .htaccess file inside public_html directory
  2. Add these codes
  RewriteCond %{HTTP_HOST} ^your-domain.com$ [NC,OR]
  RewriteCond %{HTTP_HOST} ^www.your-domain.com$
  RewriteCond %{REQUEST_URI} !your-laravel-folder/public/
  RewriteRule (.*) /your-laravel-folder/public/$1 [L]
Enter fullscreen mode Exit fullscreen mode

In the above lines you should replace the following: your-domain.com – Type your own domain name and also replace your-laravel-folder with your folder name.

Collapse
 
bangado profile image
Bangado

Hello I would like to have your help I used your path to deploy my laravel application on hostinger but I have a 403 error

Collapse
 
vikasrinvi profile image
Vikas Rinvi

I have followed the same process but now my images are not showing, It says 404 error

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

Which Images are you talking?
Assets or user storage?

Collapse
 
didarh profile image
Didar Hojagulyyev

User storage, because after uploading image,it again creates folder of public. so maybe it is better not moving files to public_html. Then What way should we do???

Thread Thread
 
pushpak1300 profile image
Pushpak Chhajed • Edited

Oops ;-( ,
I completely missed that. you have to create one symbolic link from storage folder to public_html folder.

Thread Thread
 
shubhamnayak profile image
Shubham Nayak

I Have faced the same issue with the storage folder and when I try to create a symbolic link of storage folder it shows the error -
symlink(): No such file or directory.
Please help me out with this.

Collapse
 
cangak profile image
cangak • Edited

solv the issue with artisan route:cache and route:clear
i use git instead comprezz and upload, but i have same exact folder struckture,
/home
-user
-laravel
-public_html
UnexpectedValueException
Invalid route action: [C:32:"Opis\Closure\SerializableClosure":210:{a:5:{s:3:"use";a:0:{}s:8:"function";s:44:"function () { return \view('welcome'); }";s:5:"scope";s:37:"Illuminate\Routing\RouteFileRegistrar";s:4:"this";N;s:4:"self";s:32:"000000001ac450da000000003105971b";}}].

i have try
Route::view('/', 'welcome');
or
Route::get('/', function () {
return 'Hello World';
});
it stille the same error.

by the way, my installation running well in my local computer. and there is another laravel installation in my hosting, but laravel 7 and running with no problem.
thanks in advance

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

I don't understand the question . Can you please post this on stackoverflow and share the link here?

Collapse
 
cangak profile image
cangak

sorry my bad english.
my index always return
UnexpectedValueException
Invalid route action: [C:32:"Opis\Closure\SerializableClosure":210:{a:5:{s:3:"use";a:0:{}s:8:"function";s:44:"function () { return \view('welcome'); }";s:5:"scope";s:37:"Illuminate\Routing\RouteFileRegistrar";s:4:"this";N;s:4:"self";s:32:"000000001ac450da000000003105971b";}}].

but i have solve it by artisan route:cache and route:clear

Collapse
 
adelinghanaem profile image
Adelin

It is well discouraged to use shared hosting for your Laravel 8 app, WHY ? Can you explain ?

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

laravel app needs more processing power.
Shared hosting has not that memory. if you have some complex application your application will be really slow.
But if you have some small CRUD system your application will work like a charm.

Collapse
 
atiq profile image
Atiq uz Zama

The Laravel application needs dedicated CPU and RAM based on your application traffic and concurrent session for consistent performance. On the other hand, server resources are shared between multiple applications in shared hosting, resulting in high page load time and inconsistent performance. Also, many developers need control over the server to run specific services, Php modules, change MySQL configuration or install additional software services based on application requirements.

In shared Laravel hosting, you can't change the server and software services configuration. Also no customization is allowed or significantly less control on the server.

I personally suggest Managed Laravel Hosting over cloud servers like AWS to all the developers, so you can get the freedom you want without worrying about the hosting complexities. Try Devrims Managed Laravel Hosting.

devrims.com/laravel-hosting/

Collapse
 
kirinyetbrian profile image
Kirinyet Brian

how do i auto deploy my laravel project which is in github on hostinger

Collapse
 
sakzham profile image
Saksham Jain

Very informative!

Collapse
 
ochoarobert1 profile image
Robert Ochoa

I read about 20 pages and nothing worked, you did the right solution here, everything's working, thanks man!

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

Glad ! You like it.👍😁
Thanks ❤️

Collapse
 
nikhilmuddamsetty profile image
Nikhil Muddamsetty

hello
i have a hostinger's shared hosting
can u please provide the steps how to create symbolic link?

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

Login to SSH and run this command.
ln -s souce-directory targetdirectory

Collapse
 
cangak profile image
cangak

create file in public_html
<?php symlink('/home/user/laravel/storage/app/public','/home/user/public_html/storage');
and excute it in browser

Collapse
 
mahmoodhussain profile image
Mahmood Hussain Bhat

This helped me to solve the issues of displaying assets (images) but problem still persists for uploading the images.

Collapse
 
dmitry_jpn profile image
DmitriiTolstokulakov

Hi, thanks for you explanation. How about change in bootstrap/ config.php? There is to several routs, isn't it? I would like to see them:) Thanks.

Collapse
 
titosobabas profile image
titosobabas

PHP Fatal error: Uncaught Error: Call to undefined method Composer\Autoload\ClassLoader::make() in /home/supervi7/public_html/index.php:49

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

Can you share more details if possible?

Collapse
 
rbsilvabr profile image
Rodrigo Belo da Silva

Thank you, man!

Collapse
 
pushpak1300 profile image
Pushpak Chhajed

:-))))

Collapse
 
sandeeepprajapati profile image
sandeep prajapati

image is loading why ?

Some comments have been hidden by the post's author - find out more