简体   繁体   中英

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

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.

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.

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)

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 (eg 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, eg href=" {{ route('client.show',['id'=>$client->id]) }}" . This solved the issue, however, the URL displayed included public/index.php, eg 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, ie 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(); 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM