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 ->
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 :
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
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.
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
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
Copy all files and folders ( including public folder ) in public html
Copy all content of public folder and paste it in document root ( i.e. public_html
)
Remove the public
folder
Open your bootstrap/paths.php
and then changed 'public' => __DIR__.'/../public',
into 'public' => __DIR__.'/..',
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With