Deploying Laravel 5 applications on shared hosting without the use of SSH

Abednego Edet on March 03, 2018

First, it is well discouraged to use a shared hosting for your Laravel 5 app. There are other very cheap web hosting starting from USD $7 per mon... [Read Full]
markdown guide
 

It's ok on my local. but when i upload it on my hosting, I have this error.

Forbidden
You don't have permission to access /index.php on this server.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Can you please tell me how to fix it. thank you.

 

also you can use this --> github.com/faryar76/lrm

package to run migrations and upload files without ssh

 

Change the file access permissions for public folder, the permission error will disappear, everything should work normally now, unless you missed a step :)

 

Hello,
I have developed a laravel project first time. It works fine in local.

I have VPS-1000 hosting from inmotion inmotionhosting.com/managed-vps-ho...

Which method i should follow. is it a shared hosting?

So far i tried your mentioned technique

create a folder in root folder laravel and upload all my projects files into it
then move public folder to public_html/subdomain folder

change the autoload and bootstrap path in index file (followed this 4. change the following lines (22 and 36))

update my env and config/database file with my database credential

it given an error : SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema =

used localhost instead 127.0.0.1 and also tried to change port 3306 to 33060 but failed

also i have tried.. upload full projects into public_html/subdomain folder and use htaccess to locate public index file. But same error.

Can you please tell me how to fix it. thank you.

 

After using your method to deploy my laravel app, all the pages loaded clean and easy. Big thanks for that bro. Although i have an issue with files i store in the storage/app/public directory. Uploading images to that directory is always successful but it seems impossible for me to view images from that directory to the blade view

Storage::disk('local')->url('file.jpg') seems to work on my local server but does not work on the remote server.

I did not use asset('storage/file.jpg') because I am not permitted to create a symlink on the host with ssh or php artisan

 

Let us take a look at the default Laravel 5 application structure:

app //directory
contains restricted server-side application data

app/storage //directory
contains a writeable directory used by Laravel 5 and custom functions to store data ( i.e. log files, etc... )

public //diectory
this directory is accessible to anyone on the web.

If I were you, I would upload the file to the public directory directly.

Try this:

  1. Store image here: public_path() . 'img/filename.jpg'
  2. Save the 'img/filename.jpg' in database
  3. Generate the image URL with url('img/filename.jpg') Output // http://www.your-domain.com/img/filename.jpg
 

I never recommend shared hosting for Laravel applications. There are so many problems with it. Instead you can use DigitalOcean, Linode or Vultr. Amazon web services is a good choice. You can also checkout Cloudways for one click deployment of Laravel Applications:

cloudways.com/blog/install-laravel...

 

It seems to be working fine but one problem is that while I am trying to delete some resource lets say Post. I have used:

if($editor->image != null) {
unlink(public_path().'/uploads/editor/'.$editor->image);
}

I am unable to go to that path where the image is located. How to reach that path so that I can unlink it.

 
[deleted]
 

I have error Class 'PDO' not found, is that exception related to this tutorial?

 

Nah, I think this is as a result of bad PDO installation or php.ini config file, try to install or reinstall PDO extension then restart server.
The error actually means PDO class does not exist,

 

Hi, Thanks for saving my day...!
I have an ultimate (goDaddy) plan where i host multiple web apps. That is add on domains are added and those directories are inside public_html. What will I do in this case? Where i need to put project folder and contents in public directory?

 

I am deploying on a sub domain using laravel 5.7, but I am unable to locate the index.php file in root directory of subdomain.

 

Ok, the index.php is located in public directory, but the listed changes is not making the app running.

 

HI,
Thank you for the tutorial. But as I did the same that you have mentioned, all my css, js, images are not getting displayed on the browser. What should I do, as I have checked my path also. Please help.

 

SQLSTATE[28000] [1045] Access denied for user 'root'@'localhost' (using password: NO) (SQL: select * from sessions where id = eRLLuTsdfGhYugsApdfgsdfgujtikyuh2ygfiAZ9ePXig limit 1)

 

If we're making changes to the path of Laravel's public directory. Wouldn't it be wise to let Laravel know about it by binding the paths as discussed in the given below article?

shade.codes/how-to-deploy-laravel-...

 

Thanks a lot. I was having a problem deploying a laravel project of mine. But now it's fixed.

 

You are welcome, am glad to hear that,
Cheers :)

 
 

Thank you! I needed it to start a project. I explain to clients that a shared hosting has its limitations, it is good to start but I also make recommendations to improve over time.

 

add

Order allow,deny
Deny from all

to the .htaccess file to prevent your .env file from being publicly accessible

 
 
 

when i'm public folder content move public_html but more than 2 project how to handle this

 
 
 
 
 

I've Laravel 5.6 application and I was following your steps, but there is nothing showing when I open my application site in browser. It's blank. Can you please help me?

 

Try to view source code in browser emulator

code of conduct - report abuse