[laravel] Uploading Laravel Project onto Web Server

I am trying to upload my Laravel project onto my web server, but my past two attempts have been unsuccessful. I believe I am not uploading the files to the right location.

This is my web server's structure -> WebServer Structure

Am I correct to say that I need to upload ALL of my laravel files into public_html?

This is my Laravel project's directory :

Laravel Project Directory

EDIT : I have now added all the files onto the root folder, and public into public_html, however none of my routes seem to work. (They work perfectly on localhost). Everything throws a 404

This question is related to laravel web-hosting

The answer is


If you are trying to host your Laravel app on a shared hosting, this may help you.

Hosting Laravel on shared hosting #1

Hosting Laravel on shared hosting #2

If you want PHP 5.4 add this line to your .htaccess file or call your hosting provider.

AddType application/x-httpd-php54 .php


All of your Laravel files should be in one location. Laravel is exposing its public folder to server. That folder represents some kind of front-controller to whole application. Depending on you server configuration, you have to point your server path to that folder. As I can see there is www site on your picture. www is default root directory on Unix/Linux machines. It is best to take a look inside you server configuration and search for root directory location. As you can see, Laravel has already file called .htaccess, with some ready Apache configuration.


I believe - your Laravel files/folders should not be placed in root directory.

e.g. If your domain is pointed to public_html directory then all content should placed in that directory. How ? let me tell you

  1. Copy all files and folders ( including public folder ) in public html
  2. Copy all content of public folder and paste it in document root ( i.e. public_html )
  3. Remove the public folder
  4. Open your bootstrap/paths.php and then changed 'public' => __DIR__.'/../public', into 'public' => __DIR__.'/..',

  5. and finally in index.php,

    Change

require __DIR__.'/../bootstrap/autoload.php';

$app = require_once __DIR__.'/../bootstrap/start.php';

into

require __DIR__.'/bootstrap/autoload.php';

$app = require_once __DIR__.'/bootstrap/start.php';

Your Laravel application should work now.


Had this problem too and found out that the easiest way is to point your domain to the public folder and leave everything else the way they are.

PLEASE ENSURE TO USE THE RIGHT VERSION OF PHP. Save yourself some stress :)


In Laravel 5.x there is no paths.php

so you should edit public/index.php and change this lines in order to to pint to your bootstrap directory:

require __DIR__.’/../bootstrap/autoload.php’;

$app = require_once __DIR__.’/../bootstrap/app.php’;

for more information you can read this article.