Chat with us, powered by LiveChat

This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

Here’s Why You Should Stay Away From Laravel Shared Hosting

March 28, 2019

11 Min Read
laravel shared hosting
Reading Time: 11 minutes

I have seen many noob developers (and uninformed clients) opt for shared hosting. And, the results have generally been similar: problems in app deployment and slow performance and page load speed for all users.

Developers opt to deploy Laravel on shared hosting for one reason – cost saving. Shared hosting is cheap as dirt and clients who don’t know the role of the underlying hosting solution in the app performance prefer shared hosting to save project costs. Similarly, developers generally install and deploy Laravel to shared hosting without considering the problems it causes for the end users.

In the age where VPS and cloud based hosting are within the budgets of almost everyone, it is surprising that Laravel shared hosting is still a thing.

In this article, I will describe the pitfalls of deploying Laravel on Godaddy or Hostgator (two popular shared hosting providers) and why cloud hosting offers a far superior alternative to slow shared hosting solutions.

Shared Hosting

Shared hosting is a type of hosting service that allows multiple websites to share a physical web server and  its resources. It means that multiple websites share a single hosting server.

The Shortcomings of Shared Hosting

While the cost factor is very tantalizing, shared hosting solutions come with a whole set of serious issues with the potential of souring the deal for almost every user.

Multiple Sites Hosted on a Single Server

One of the major drawbacks of shared hosting is that there are many other websites – apart from your own – that share the same server.

Bandwidth & Disk Space

With shared hosting, all you get is a limited bandwidth and disk space on a server.

Security

If you have a shared hosting server, then your website is not secure. The hackers are there looking for easy prey. This is a big concern. In order to save your website from the evil eyes of the hackers, you must opt for a dedicated managed hosting service, instead of shared hosting.

You Might Also Like: An Overview of the Best Laravel Security Practices

No SSH Terminal

With shared hosting service, you don’t get any SSH Terminal. Hence, it’s a big No, as missing SSH Terminal can be disastrous for your website.

Server Performance and Response Time

On shared hosting, unexpected web traffic could affect the server’s limited bandwidth resources. This will ultimately result in slow response or loading time. Almost every Laravel app deployed on shared hosting will experience 500 error because of server performance.

You Might Also Like: Ultimate Laravel Performance Optimization Guide

Image Credit: Dribbble

Why You Should NOT host Laravel on Shared Hosting Servers?

If you are using shared hosting, don’t ever think of deploying a Laravel application. The two simply don’t match and fit well with each other. Today, everyone is looking for a cheap hosting service, without knowing the cost that they will have incur in the future.

For a Laravel application to work smoothly, security and performance of your website hold the key, as they are the two important aspects. And shared hosting compromises both of these aspects. This is the reason why I strongly warn you against deploying Laravel app on shared hosting servers.

Powerful Laravel Hosting For All Your Needs

Grow your Laravel app with our feature-rich managed hosting

SSH or Command Terminal

You must know that most shared hosting service providers don’t offer SSH Terminal feature. Also there is no version control support available, hence, being a developer, you have limited options to work with. You can work with FTP only.

Most of the developers remain highly critical and discourage deployment of Laravel app via FTP. Moreover, if there is no SSH Terminal available, you won’t have any access to composer, artisan or any other command line tools to work with.

Cron Jobs

If you are using shared hosting service, you will find scheduling Cron Jobs extremely difficult. This holds true for Laravel-based applications as well, as you will be unable to set task scheduling functionality on shared hosting websites.

Application Backup

One of the biggest concerns when using Laravel shared hosting is the lack that there is no application backup facility available. If the data is lost, it’s lost forever. Therefore, shared hosting is not a option for Laravel applications.

Security and Performance

Finally, website security and performance are important issues that developers tend to face. By moving everything into your DocumentRoot you expose your application to unconcerned people, most notably, hackers, which leaves you vulnerable to malicious attacks against your website. At this point you should seriously consider to switching to a different web host which is more suited to host PHP frameworks like Laravel.

You Might Also Like: PHP Migration is Easy With This Guide

Another related problem in shared server performance is the frequent 500 and related errors for Laravel apps. These are caused mainly because of limited resources and issues in server setup.

The Tedious Process of Deploying Laravel on Shared Hosting Servers

There are many shared hosting providers, including GoDaddy, Hostgator, Namecheap etc, providing shared hosting services. Deployment of Laravel application on shared hosting offers many challenges that include but are not limited to:

  1. First you need to compress your Laravel application folder you will get laravelapp.zip
  2. Second , open your Laravel Godaddy or Laravel Hostgator hosting cPanel .
  3. Click on File manager option and next click to upload button on top menu.
  4. Next , unzip laravelapp folder.
  5. Open the laravelapp folder and MOVE the CONTENTS of the public folder to your cPanel’s public_html folder. You can as well delete the empty public folder now.
  6. Navigate to the public_html folder and locate the index.php file. Right click on it and select Code Edit from the menu.
  7. This will open up another tab showing the cPanel code editor.
  8. Change the following line
`require __DIR__.'/../bootstrap/autoload.php';

...

$app = require_once __DIR__.'/../bootstrap/app.php';`

to

`require __DIR__.'/../laravel50/bootstrap/autoload.php';

...

$app = require_once __DIR__.'/../laravel50/bootstrap/app.php';`
  1. Then you set your .htaccess file configuration according to your website domain and url settings.
  2. Finally you open PHPMYADMIN and create new database for your application and migrate all tables for application you like to used.

These are the steps you will have to follow when you deploy Laravel application on shared hosting. Sometimes, you will taste success, but in most cases, all your efforts will go in vain. The case may be you are unable to find a suitable PHP version to support your Laravel application. Or you will end up with a 500 error.

The Easy (and Not so Costly) Solution

Now, you know why shared hosting is not a good option for Laravel-based apps. You don’t worry though. We have got you covered with a perfect solution for all your Laravel hosting issues. It’s none other than cloud hosting.

Why Cloud Hosting ?

Using managed cloud hosting services like the one provided by Cloudways, you can easily deploy Laravel to your server in just a click via Git or SSH terminal, backed up by excellent web security features. Cloud hosting is the process of outsourcing an organization’s computing and storage resources to a service provider that offers its infrastructure services.

Benefits of Cloud Hosting

The benefits of cloud hosting outnumber the benefits of shared hosting. Let’s read about these advantages briefly.

Reliability

Reliability is one of the most important features that cloud hosting offers. Rather than hosting your website on a shared server, it’s better to host your website on a dedicated virtual cloud server which draws its resource, such as disk space, from an extensive network of underlying physical servers. If one server goes offline it will have no effect on availability, as the virtual servers will continue to pull resource from the remaining network of servers.

Scalability

Cloud hosting servers offer scalability for your websites, as the resources are available in real time on demand and not limited to the physical constraints / capacity of an individual server. For example, if a client website demands an extra resource from its hosting platform due to a spike in visitor traffic or the implementation of new functionality, the resource is readily available and the client can access it easily without any hassle.

Performance & Security

When it comes to the performance and security for your Laravel apps, cloud hosting offers the best possible solutions. Unlike shared hosting, there is little chance of running out of server resources (you can always scale up when the graphs start to hit the upper limits), and thus the performance of the application doesn’t suffer. Similarly, cloud hosting comes with better security features that are delivered by competent engineers. At the minimum, the security features include a firewall and a whitelist of IP addresses.  

Cloud Hosting Providers

Popular cloud hosting service providers include Amazon Web Services (AWS), Google’s GCE hosting, DigitalOcean (DO), Linode, and Vultr. AWS offers its Elastic Compute Cloud (EC2) servers to handle compute services, along with Amazon Simple Storage Service (S3) and Amazon Glacier for storage. Google offers its Google Compute Engine (GCE) and Google Cloud Storage for the enterprise. Digital Ocean , Linode and Vultr also provide excellent and reliable cloud hosting services.

You Might Also Like: What Should you know About AWS EC2 Hosting Server

All these cloud hosting platforms come packed with their own distinctive features and hosting plans. In order to handle and manage the server load, big organizations often hire system admins – a practice that incurs a lot of cost in terms of human capital. In order to run organizational operations in a more efficient manner, most of the companies are now turning to managed cloud hosting services. ‘Managed’ is the key word here.

Managed Cloud Hosting with Cloudways

If you type the phrase ‘managed cloud hosting’ in Google’s search bar, you see a long list of managed hosting providers that claim to manage your application and server without any hassle. There is a Catch-22 here.

You must look for managed cloud hosting platform, you have to check out the features that these managed cloud hosting services provide. Are they reliable? Are they efficient enough? Are they user friendly? I know that it’s not easy to decide from amongst the number of hosting service providers, including GoDaddy, BlueHost, and many others.

But there is one cloud hosting service provider that enjoys a handsome competitive advantage over all other hosting service providers, in terms of user-friendliness, efficiency, server scaling, performance, and pricing. It’s none other than Cloudways!

Simplicity

On Cloudways managed hosting platform you can easily manage AWS, DO, GCE, Linode and Vultr servers, thanks to a rich set of features that harness security and performance of your website.

Thunder Stack for Optimized Performance

For smooth and optimized performance of Laravel application,  Cloudways provides an optimized stack with advanced caching mechanism. They also offer a dedicated CDN to help you curb down your web page load time issues, thus ensuring speedy access to your website.

Read More: Laravel Websites Hosted on Cloudways Loads Faster – Check Out The Benchmarks

How Cloudways Adds Value to Your Laravel Apps?

  • Cloudways provides features to deploy Laravel application on different cloud servers (AWS, DO, LINODE, VULTR). You can install Laravel in just minutes.
  • Provides latest Laravel 5.7 version with PHP 7 ready servers.
  • Supports Redis cache. Enabling Redis improves the performance of databases. Combined with Apache, NGINX, and Varnish, this gives you the ultimate and unbeatable web performance.

Using Cloudways managed hosting platform, you can easily deploy your Laravel applications. You just have to select your Laravel application version, for instance, Laravel 5.7 and submit all application details. Then select your cloud hosting server. You can also change your server size according to your clients’ requirements.

You Might Also Like: Install Laravel 5.8 on Server

In Application Management tab, you can find many other features like, Security, Deployment via Git, Cron job Management, Application Settings, and CloudwaysCDN.

Cloudways also provides Free SSL certificates which you can install ssl in just one click. You can also create a whitelist of IPs, making it easy to collaborate with networks or regions with unrestricted access to SSH and SFTP.

Cloudways also offers real-time server monitoring service round the clock. You can keep track of over 16 different metrics from the comfort of the console.

In Manage Services tab , you can easily check all services in real-time, like Apache server, Memcached, New Relic, PHP FPM, Redis, and Varnish etc.

Cloudwaysbot: The AI-based smart assistant that tracks real-time performance, helping you to monitor your Laravel application performance via AI.

Cloudways also offers New Relic integration that enables smooth and flawless app performance, so as to help you troubleshoot and identify issues easily.

For collaboration, Cloudways provides Git auto-deployment that allows you to get updated code deployed on live servers as soon as the changes in the remote repositories occur.

What Does People Say About Shared Hosting?

Ilias Loulakakis: I have some Laravel applications running on shared hosting, the limitations are mostly restrictions on resources(cpu, memory, etc) and ssh server commands.I do not recommend shared hosting. Only when you really have to.. Every project has its own needs, but you will always find a vps usefull. Also setting up and maintaining a vps will help you get better at server administration
Kay Nguyễn: Root folder, can’t use storage link, etc…

billcube

Depends on your host. If you have ssh access, crontab and the ability to point your website to the /public directory, no problem. There are drawbacks, but nothing that isn’t manageable, contrary to my initial belief. I currently have 2 Laravel apps in production on shared hosting.

The most glaring issue is the lack of console commands. You can just use Voyager for that. Or the schedule command found in your app/Console/Kernel.php. Or just use Artisan::call(). My preferred approach is Voyager. I typically use artisan:down through the admin panel and later delete the generated downfile inside the ../storage/frameworkdirectory when I want to bring it back up (because you can no longer access example.com without running into an HTTP 500 error after you’ve run artisan:down).

For migrations and anything that requires that the app not be in production, I put the app into maintenance mode than change my APP_ENV to “local” inside my .env.

That or you can use good ol’ Cron jobs to use the Artisan CLI. I found that entirely unreliable for anything other than creating a symlink once I’ve deployed my app, so it’s a one-time thing, really. There are libraries out there (like Voyager) that make shared hosting + Laravel manageable though, so I wouldn’t worry.

lmusliu

Speaking from personal experience. I tried to cheap out and host my laravel app on shared hosting. You will face a number of challenges: Unable to use the console (hence you can’t use php artisan commands), You don’t have control over your application and a lot more that i can’t even count. Getting VPS hosting now it’s really cheap and setting up everything its a breeze just follow the documentation.

Q: How to solve Laravel error 500?

A: To solve error 500 in Laravel, first you need to execute the following command:
sudo chmod -R 755 laravel_blog
Then, type the below command that allows Laravel to write file to the storage folder:
chmod -R o+w laravel/storage
Here, Laravel is the name of directory where the application is installed.

Q: How to rewrite rules in Laravel shared hosting htaccess?

A: To rewrite rules in Laravel app that is deployed on a shared hosting, just type the below given commands in .htaccess. This method assumes that your DOCUMENT_ROOT is perfectly setup by your Apache server:
.htaccess
RewriteEngine on
# serve existing files in the /public folder as if they were in /
RewriteCond %{DOCUMENT_ROOT}public%{REQUEST_URI} -f
RewriteRule (.+) /public/$1 [L]
# route everything else to /public/index.php
RewriteRule ^ /public/index.php [L]

Q: What are the hosting requirements for Laravel?

A: To make Laravel apps perform flawlessly over the web, there are certain requirements a hosting server should fulfill. Firstly, it should provide SSH access, so that users can easily install/integrate Composer or Github functionality on the server. Secondly, a hosting server should provide optimum web speed, so that apps could get required bandwidth and speed to function properly. Web servers like Apache, NGINX and others speed optimization tools always comes pretty handy in enhancing app performance.

Final Words

Developers and agencies  are still using Laravel shared hosting services due to many reasons that include but are not limited to the fact that they have low client budget or less requirements about security and backup.

In this article, I have elaborated in detail about the different disadvantages you face when you deploy Laravel app on shared hosting server. Instead you must opt for a managed cloud hosting server to deploy your Laravel app to reap the unprecedented benefits in the long run.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Launch Laravel apps with 1-Click Install. Painless Server Management

Deploy your apps on optimized Laravel hosting servers.

Pardeep Kumar

Pardeep is a PHP Community Manager at Cloudways - A Managed PHP Hosting Platform. He love to work on Open source platform , Frameworks and working on new ideas. You can email him at pardeep.kumar@cloudways.com

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!