In the first use case, the most common; Let's imagine that I need to upload my project to the root of my website, that is, in “www.example.com” and we know that this root directory in most cases is a folder called public_html.
Now what we need to do next is copy all the files inside the public folder of what we just uploaded and place them inside public_html. In this way the index.php that will be there will be the one of our application in Laravel.
Upload Laravel Project to Shared Server
With this, all the content that was inside shared_project/public is now inside our public_html directory.
The next thing we need to do is edit the index.php file in which we now need to point to a new require path. In this file you must look at the following lines (for now line 22 and line 36)
And you must change them pointing to where they are currently, for this example (It should be noted that you can locate your files where it is most comfortable for you).
In this way, when entering our domain www.example.com, at least it should throw us a Laravel error. Although doing this should already work for you.
Use Case 2:
In case you need to upload your project not in the root of your domain, but inside a folder, either because you have WordPress installed or something else. Instead of copying the public files into public_html, you should copy them to a separate folder.
For example if you want it to be inside www.example.com/laraveles you must cut your public folder from your project and paste it inside your public_html directory, and then rename it as you want, if you rename it laraveles you will be able to access /laraveles.
The rest of the steps are the same for everyone, only you have to check the theme of the routes inside the index.php
How you organize your folders is your decision, and it depends on how you feel more organized. You just have to take care that everything is well declared so that no route fails.
Edit Service Provider
If by any chance your JS and CSS files don't load, this is because we've moved the location of the public folder, this can be fixed by telling Laravel a new public path.
This is inside a ServiceProvider, for the example we have used AppServiceProvider, inside the register method you must place your new route.
With this it should be solved, if not, you have made the serious mistake of using relative paths to load your resources instead of using the Laravel helpers as is the case with asset().
Upload Database
Since we cannot execute the migrations, unfortunately we will have to upload our database as we did in the 90s. That is, by dumping your Database in Local, log in to your phpMyAdmin and import the dump in it . I think this is not very complicated, so I think it is not necessary to detail this point, but if you have any questions, leave it in the comments.
Setting Environment Variables
Let us remember that in our .env file there is part of the important configuration for our application to work, in this you must place the configuration of your application, your access data to the Database, and if you are going to use the mail service, place the data.
In the first use case, the most common; Let's imagine that I need to upload my project to the root of my website, that is, in “www.example.com” and we know that this root directory in most cases is a folder called public_html.
Now what we need to do next is copy all the files inside the public folder of what we just uploaded and place them inside public_html. In this way the index.php that will be there will be the one of our application in Laravel.
Upload Laravel Project to Shared Server
With this, all the content that was inside shared_project/public is now inside our public_html directory.
The next thing we need to do is edit the index.php file in which we now need to point to a new require path. In this file you must look at the following lines (for now line 22 and line 36)
And you must change them pointing to where they are currently, for this example (It should be noted that you can locate your files where it is most comfortable for you).
In this way, when entering our domain www.example.com, at least it should throw us a Laravel error. Although doing this should already work for you.
In case you need to upload your project not in the root of your domain, but inside a folder, either because you have WordPress installed or something else. Instead of copying the public files into public_html, you should copy them to a separate folder.
For example if you want it to be inside www.example.com/laraveles you must cut your public folder from your project and paste it inside your public_html directory, and then rename it as you want, if you rename it laraveles you will be able to access /laraveles.
The rest of the steps are the same for everyone, only you have to check the theme of the routes inside the index.php
How you organize your folders is your decision, and it depends on how you feel more organized. You just have to take care that everything is well declared so that no route fails.
Edit Service Provider
If by any chance your JS and CSS files don't load, this is because we've moved the location of the public folder, this can be fixed by telling Laravel a new public path.
This is inside a ServiceProvider, for the example we have used AppServiceProvider, inside the register method you must place your new route.
With this it should be solved, if not, you have made the serious mistake of using relative paths to load your resources instead of using the Laravel helpers as is the case with asset().
Upload Database
Since we cannot execute the migrations, unfortunately we will have to upload our database as we did in the 90s. That is, by dumping your Database in Local, log in to your phpMyAdmin and import the dump in it . I think this is not very complicated, so I think it is not necessary to detail this point, but if you have any questions, leave it in the comments.
Setting Environment Variables
Let us remember that in our .env file there is part of the important configuration for our application to work, in this you must place the configuration of your application, your access data to the Database, and if you are going to use the mail service, place the data.