Wesley
Wesley

Reputation: 1009

Laravel on shared hosting - subdomain

I am trying to deploy my laravel application on a shared hosting. It should be deployed in www.subdomain.something.com

My folder structure is:

    /laravel
       app/
       vendor/
       bootstrap/
       server.php
       artisan
       composer.json
       composer.lock
       phpunit.xml
   /public_html
       subdomain/
       index.php

My index.php have the following paths:

require '/../../laravel/bootstrap/autoload.php';
$app = require_once '/../../laravel/bootstrap/start.php';

My paths.php

'app' => __DIR__.'/../../laravel/app',
'public' => __DIR__.'/../../public_html/subdomain',
'base' => __DIR__.'/../../laravel',
'storage' => __DIR__.'/../../laravel/app/storage',

Can anyone see what I am missing? I tried google, and found a bunch of step-by-step explanations but nothing seems to work - It results in a 500 internal server error.

Thanks for any feedback

Wesley

Upvotes: 4

Views: 5285

Answers (4)

user761100
user761100

Reputation: 2307

I tried to deploy my first Laravel 8 application on shared hosting on DreamHost, and did encounter some issues.

  1. First I was not able to use composer. Composer 1 was available however, I was unable to upgrade it to Composer 2. ( Was getting errors)
  2. Finally, I ended up uploading all files from my local system to the subdomain root folder (e.g. cota.mydomain.com)
  3. When I tried cota.mydomain.com, I got 404 error.
  4. When I changed url to cota.mydomain.com/public/index.php, the application started working. However, all href links which were defined like href="/home" or href="/client/create" started giving 'not found' errors. To fix this issue I had to use named routes in href, e.g. href=" {{ route('client.show',['id'=>$client->id]) }}". This solved the issue, however, the URL displayed included public/index.php, e.g. cota.mydomain.com/public/index.php/client/show/1.
  5. To further fix the problem, I changed the web folder (root folder) for my subdomain to include public, i.e. cota.mydomain.com/public
  6. Next I added an index.php in cota.mydomain.con with the following contents header("Location: http://www.cota.mydomain.com/public/index.php"); die();
  7. This fixed all issues, including remving public and index.php from link URLs.

Upvotes: 0

Md Nozibulla Bashar
Md Nozibulla Bashar

Reputation: 675

Follow the first rule here. If you use the first rule then everything should work fine. But somehow if you face 500 Internal Server Error then login to ur server public_html directory through ssh and give the following command.

sudo chmod 755 -R laravel

chmod -R o+w laravel/storage

Here laravel is your Laravel project directory.

Upvotes: 2

ErcanE
ErcanE

Reputation: 1641

I was having similar problem and found the solution.Maybe someone can get help with this,

Install LARAVEL 5 Locally Same as Share Hosting Directory (Deploy L5 Share Hosting Solution)

Upvotes: 0

dasper
dasper

Reputation: 722

Make sure you have write permissions to app/storage/ and all the sub directories. This sounds like the culprit but if not then see if you get any errors in the app/storage/logs dir. If not see if you can parse the server logs.

Upvotes: 0

Related Questions