Configure Laravel 5 for Shared Hosting
There are a few things that you have to change in Laravel to make it work on shared hosting. The most important thing is to change the public path and correctly bootstrap the application.
I recently had to build a website that would be used on shared hosting. At first I went with a standard HTML
index.html file and then create a file called
contact.php to handle the contact form submit action. The website can be found at studio-renata.hr as soon as they move the website to the server that has PHP 5.6 version.
As I started coding the website the number of lines started to grow and I had a lot of duplicating syntax for stuff like images, containers etc.. Somehow I got over it and was feeling happy with it, but then I had to deal with validating the contact form using AJAX. As you can guess I did a quick research and found out that Laravel can run on shared hosting, but with a few limitations:
- There is no console (artisan)
- You cannot use Composer to install/update
- You cannot use Git to version your application
That being said, there are a few requirements that your server needs to have in order for Laravel to work:
- PHP >= 5.5.9
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
To be honest, I haven't checked that my shared hosting server has mentioned PHP extensions, but since it all works I guess that it does.
In this lesson I will show you how to configure your Laravel application to be able to run on shared hosting. You can view the code for this lesson on GitHub.
- Cover image Fruits! created by Ana Maria Ochoa
To continue reading, choose a subscription plan: