Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 508
Sainath Krishnan Avatar asked Feb 27 '14 17:02

Sainath Krishnan


People also ask

Where can I upload Laravel project?

just paste it in the root folder of the laravel project. Now, compress all laravel project folders or files including public folder to zip format. We will upload this zip file to the public_html folder on shared hosting. Open File Manager in cPanel, then go to public_html.


2 Answers

No, but you have a couple of options:

The easiest is to upload all the files you have into that directory you're in (i.e. the cPanel user home directory), and put the contents of public into public_html. That way your directory structure will be something like this (slightly messy but it works):

/     .composer/     .cpanel/     ...     app/                 <- your laravel app directory     etc/     bootstrap/           <- your laravel bootstrap directory     mail/     public_html/         <- your laravel public directory     vendor/     artisan              <- your project's root files 

You may also need to edit bootstrap/paths.php to point at the correct public directory.

The other solution, if you don't like having all these files in that 'root' directory would be to put them in their own directory (maybe 'laravel') that's still in the root directory and then edit the paths to work correctly. You'll still need to put the contents of public in public_html, though, and this time edit your public_html/index.php to correctly bootstrap the application. Your folder structure will be a lot tidier this way (though there could be some headaches with paths due to messing with the framework's designed structure more):

/     .composer/     .cpanel/     ...     etc/     laravel/      <- a directory containing all your project files except public         app/         bootstrap/         vendor/         artisan     mail/     public_html/  <- your laravel public directory 
like image 107
alexrussell Avatar answered Sep 28 '22 01:09

alexrussell


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.

like image 40
Raj Sf Avatar answered Sep 28 '22 02:09

Raj Sf