Laravel is a powerful PHP framework, but it requires a specific folder structure that does not fully match the standard setup of our shared hosting. In this article, we explain how to correctly deploy Laravel on a Easyhost hosting package.
Not possible by default
On a Easyhost hosting package, your website is loaded by default from the www folder.
Laravel, however, expects the publicly accessible files to be located in the public folder.
This creates a conflict:
- Hosting expects:
www - Laravel expects:
public
If you do nothing, your website will not work correctly or may not be visible at all.
Solution: symlink from www to public
The recommended solution is to create a symbolic link (symlink) from the www folder to the public folder.
This way:
- The hosting still sees a
wwwfolder - But the files are actually served from Laravel’s
publicfolder
Step 1: Upload your Laravel project
Upload your full Laravel project to your hosting package, for example via FTP or Git.
Make sure the structure looks roughly like this:
/home/username/
├── app
├── bootstrap
├── config
├── public
├── resources
├── routes
└── ...
Step 2: Rename the existing www folder
Rename the www folder to something like www_old
Step 3: Create a symlink via SSH
Connect to your hosting via SSH and run the following command:
ln -s public www
What does this do?
- www becomes a reference to public
- The web server thinks it is serving from www
- But in reality, it uses Laravel’s public folder
Alternative solution
Instead of using a symlink, you can also modify Laravel so that the framework uses the www folder instead of public.
This requires changes in the Laravel configuration and is less recommended.
More information can be found here:
https://developerhowto.com/2018/11/12/how-to-change-the-laravel-public-folder/