DEV Community

Cover image for Can You Really Host Laravel on Shared Hosting?
webfuelcode
webfuelcode

Posted on

Can You Really Host Laravel on Shared Hosting?

Laravel 11 introduces numerous updates, and I opted to utilize Tailwind CSS due to its readily available theme upon installation.

Code-ready setups are generally preferable. However, utilizing older versions of Bootstrap can present challenges if project requirements are not carefully considered. For instance, the order-md-1 class, which does not function in older versions, has been a frequent source of error in my experience.

Tailwind CSS was selected due to its comprehensive functionality compared to Bootstrap, eliminating the need for additional JavaScript libraries. This feature set was a primary motivator for exploring Tailwind CSS once.

It is a separate matter that the production file must be executed upon completion of all other tasks.

Can you run a Laravel project on shared hosting?

The simple answer is yes. I was curious about placing the tailwind production file if I go to host on a shared environment.

In the previous version of Laravel and using Bootstrap, we just moved the file from the public folder to the root folder. Then update the paths in the index file.

And it is done. In some instances, clearing the cache or adjusting the PHP version was necessary. In this particular case, switching to a different PHP version resolved the problem.

The same thing still works but I was stuck on Tailwind CSS and the style was broken. So I tried different methods.

HTACCESS

The solution is still the same. But this never worked for me on older versions and Bootstrap.

But this time I had no option. Because the Tailwind does not work on Laravel 11, so I decided to keep all the files in their places and create .htaccess file in the root.

And all worked properly. This was the most simple task to start with Laravel.

Copy this

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/$1 [L]
Enter fullscreen mode Exit fullscreen mode

Top comments (0)