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 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.
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
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.
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.
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.
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.
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:
- First you need to compress your Laravel application folder you will get laravelapp.zip
- Second , open your Laravel Godaddy or Laravel Hostgator hosting cPanel .
- Click on File manager option and next click to upload button on top menu.
- Next , unzip laravelapp folder.
- 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.
- Navigate to the public_html folder and locate the index.php file. Right click on it and select Code Edit from the menu.
- This will open up another tab showing the cPanel code editor.
- Change the following line
$app = require_once __DIR__.'/../bootstrap/app.php';`
$app = require_once __DIR__.'/../laravel50/bootstrap/app.php';`
- Then you set your .htaccess file configuration according to your website domain and url settings.
- 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 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.
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), GCE, 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.
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.
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.
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.
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?
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.
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.
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.
Launch Laravel apps with 1-Click Install. Painless Server Management
Deploy your apps on optimized Laravel hosting servers.