Deploy Laravel 5 using only FTP in a shared hosting

左心房为你撑大大i 提交于 2019-11-28 08:19:49

There is no difference between L4 and L5, so do the same thing you did for L4.

  1. I create a new folder named "protected"
  2. Move all except "public" folder into "protected" folder
  3. Move all inside "public" folder to root
  4. Edit index.php in root folder(from public folder),

edit require __DIR__.'/../bootstrap/autoload.php'; into require __DIR__.'/protected/bootstrap/autoload.php';

also edit $app = require_once __DIR__.'/../bootstrap/app.php'; into $app = require_once __DIR__.'/protected/bootstrap/app.php';

UPDATE
This is a risky process. By using this, you give malicious users permissions to find bugs. like, http://project-url/storage/logs/laravel.log is still open.


Previous Answer:
Those who hardly check the comments, @Andrew F. has already given the answer.
but he missed some other files like composer and package.
Formatted answer is:

  1. move every file in public to parent folder.
  2. update paths in index.php.
  3. add the following line to .htaccess:
    RewriteRule ^(server\.php|gulpfile\.js|\.env|composer.*|package.*) - [F,L,NC]

If you are trying to run Laravel 5.1 into a shared hosting space or you are trying to put your laravel 5/5.1 into a sub directory on your shared hosting so you can access it like this:

http://mywebsite.com/mylaravel/

So this answer is for you, first of all make sure you meet

Laravel 5.1 requirements :

- PHP 5.5
- PHP extension Mcrypt
- PHP extension Mbstring
- PHP extension OpenSSL

Here two tutorials for you :

Link 1

Link 2

In Apache, you can achieve this something like

    RewriteEngine on
    RewriteBase /

  # Rewrites all URLS without blog in them
    RewriteCond %{REQUEST_URI} !^/blog/

  # Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
    RewriteCond %{HTTP_HOST} ^(www\.)?example\.

  # Rewrite all those to insert /folder
    RewriteRule ^(.*)$ /blog/$1 [L]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!