Laravel 5 is not working on shared hosting

▼魔方 西西 提交于 2019-12-06 05:46:18

I have referred this link laravel.io

Finally, I did the job on my shared hosting. This is what I did

  1. Setup a project Laravel 5 in localhost correctly configured
  2. Double check the server configuration of PHP 5.4 (this because every little change on .htaccess file may change that config)
  3. Create a directory in the same level of public_html and put the project inside of that folder.
  4. Put the content of public (L5) directly on public_html (be aware of don't overwrite the .htaccess file accidentally)

Now... This is the "tricky part"... I see this structure

mail

perl5

php

public_html

[framework-folder]

ssl

Inside of public_html I can see all the files of public directory of Laravel 5 Go to index.php and edit the line 22

From this require __DIR__.'/../bootstrap/autoload.php';
To this require __DIR__.'/../[framework-folder]/bootstrap/autoload.php';

And the line 36

From this $app = require_once __DIR__.'/../bootstrap/app.php';
To this $app = require_once __DIR__.'/../[framework-folder]/pulcro/bootstrap/app.php';

The final step is to edit the .htaccess file and add some lines

RewriteEngine On
# Redirect Trailing Slashes...
RewriteCond %{REQUEST_URI} !^
RewriteRule ^(.*)$ /$1 [L]

and update [framework-folder]/server.php

From this require_once __DIR__.'/public/index.php';
To this require_once __DIR__.'/public_html/index.php';

Refresh the cache of my browser and.. Victory!! I know that this is not the absolute right way to install the framework (God, I never spoke about Composer) But... It's working for me now Hope that this can help somebody in order to deploy Laravel 5

thanks to Neeraj Rathod, but I found this article more useful, and of course simple more!

WHY AM I GETTING A 500 INTERNAL SERVER ERROR MESSAGE?

in my case, by reading that article I found out from my "error pages" that the "group writable" permission must not be set for "index.php" file inside "public" folder and also for all folders through route. also you have to check that your shared hosting php version is more than 7.0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!