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
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):
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
inpublic_html
, though, and this time edit yourpublic_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):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
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 youOpen your bootstrap/paths.php and then changed
'public' => __DIR__.'/../public',
into'public' => __DIR__.'/..',
and finally in index.php,
Change
into
Your Laravel application should work now.
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 yourbootstrap
directory:for more information you can read this article.
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 :)
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.