Many beginner developers (and uninformed clients) opt for shared hosting and experience app deployment issues, slow performance, and low page load speeds.
Developers opt to deploy Laravel on shared hosting mainly for cost savings. Shared hosting is cheap and is generally preferred by those unaware of its detriments. Similarly, developers generally install and deploy Laravel to shared hosting without considering the problems it causes for the end-users.
- Shared Hosting
- Laravel Shared Hosting
- The Shortcomings of Shared Hosting
- Why You Should NOT host Laravel on Shared Hosting Servers?
- Laravel Shared Hosting Deploy Process
- The Easy (and Not so Costly) Solution
- Why Should You Use Cloud Hosting for Laravel?
- Benefits of Cloud Hosting
- Cloud Hosting Providers
- Managed Cloud Hosting with Cloudways
- How Cloudways Adds Value to Your Laravel Apps?
- What Do People Say About Shared Hosting?
- Final Words
In the age where we have budget-friendly VPS and cloud-based hosting solutions, it is surprising that Laravel shared hosting is still a thing.
This article discusses 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.
But before that, let’s learn the basics of shared hosting.
Shared hosting is a service that allows multiple websites to share a physical web server and its resources. It includes sharing a single hosting server by multiple websites causes speed, performance, and security issues.
Laravel Shared Hosting
Shared hosting used for Laravel Applications can cause the following difficulties;
- You are only allowed to use a limited amount of bandwidth & disk space
- Require migration to a dedicated or managed server later
- You might not have access to SSH Terminal
- Slow and compromised application performance
Improve Your Laravel App Speed by 300%
Cloudways offers you dedicated servers with SSD storage, custom performance, an optimized stack, and more for 300% faster load times.
The Shortcomings of Shared Hosting
While the cost factor is very tempting, 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 many other websites – apart from your own – share the same server. This causes sluggishness and makes your sites vulnerable to security issues.
Bandwidth & Disk Space
Shared hosting givesyou limited bandwidth and disk space on a server, causing scalability and speed issues
Lack of Admin Access
Lack of admin access means your access is limited to perform administrative tasks. For example, if you need to send software different from the hosting provider’s standard, you won’t be allowed to do that. And your need for root might affect your capacity to perform a few tasks.
Sharing the host server for numerous websites welcomes crashes and speed issues. When aserver is loaded with more websites, the activity increases, and the process of searching gets slower. Consequently, the system crashes and collapses.
Your website is insecure with a shared hosting server. Hackers are out there looking for easy prey, and shared hosting makes your sites vulnerable to their attacks To save your website from the evil eyes of 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 a 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
Unexpected web traffic can affect the server’s limited bandwidth resources on shared hosting, ultimately resulting in a slow response or loading time. Almost every Laravel app deployed on shared hosting experiences the 500 error because of server performance.
You Might Also Like: Ultimate Laravel Performance Optimization Guide
Why Should You Avoid Hosting Laravel on Shared Hosting Servers?
If you use shared hosting, don’t ever think of deploying a Laravel application. The two simply don’t match and fit well with each other. These days, everyone is looking for a cheap hosting service without knowing the cost they will incur in the future.
Your website’s security and performance are critical for a Laravel application to work smoothly. And shared hosting compromises both of these aspects. This is the reason why I strongly warn you against deploying the Laravel app on shared hosting servers.
SSH or Command Terminal
Most shared hosting service providers don’t offer SSH Terminal features. Also, there is no version control support available,. Hence, being a developer, you have limited options, and you have to only work with FTP.
Most developers remain highly critical of the deployment of the Laravel app via FTP. Moreover, if there is no SSH Terminal available, you won’t have access to the composer, artisan, or any other command-line tools.
If you use a shared hosting service, you will find scheduling Cron Jobs extremely difficult. This holds 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 of an application backup facility. If you lose any data, it’s lost forever. Therefore, shared hosting is not a recommended option for Laravel applications.
Security and Performance
Website security and performance hold extreme importance for developers. By moving everything into your DocumentRoot, you expose your application to hackers, which leaves you vulnerable to malicious attacks. So, you must consider switching to a different web host more suited to host PHP frameworks like Laravel.
You Might Also Like: PHP Migration is Easy With This Guide
Also, with shared hosting, you will experience countless errors, including the 500 error. These errors are caused mainly due to limited resources and server setup issues.
Laravel Shared Hosting Deploy Process
- Many shared hosting providers, including GoDaddy, Hostgator, Namecheap, etc., provide shared hosting services . Deployment of Laravel application on shared hosting is a lengthy process and includes the following steps:
- 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 the File manager option and next click to upload button on the top menu.
- Next, unzip the 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
`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';`
- Then you set your .htaccess file configuration according to your website domain and URL settings.
- Finally, you open PHPMYADMIN and create a new database for your application and migrate all tables for the application you like to use.
These are the steps you will have to follow when you deploy the 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 an ideal option for Laravel-based apps. But, we have got you covered with a perfect solution for all your Laravel hosting needs. And it’s none other than cloud hosting.
Why Should You Use Cloud Hosting for Laravel?
Cloud hosting is the process of outsourcing an organization’s computing and storage resources to a service provider that offers its infrastructure services. Using managed cloud hosting solutions like Cloudways lets you easily deploy Laravel to your server in just a click via Git or SSH terminal, backed up by excellent web security features.
Benefits of Cloud Hosting
The future is cloud, and is the recommended solution for all your Laravel needs. Let’s learn how you can benefit from cloud hosting:
Reliability is among the key cloud hosting features. Rather than hosting your website on a shared server, it’s better to host on a dedicated virtual cloud server that draws its resource, such as disk space, from an extensive network of underlying physical servers.
If one server goes offline it will not affect your site’s availability, as the virtual servers will continue to pull resources 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 are not limited to an individual server’s physical constraints/capacity.
Suppose a client website demands an extra resource from its hosting platform due to a spike in visitor traffic or the implementation of new functionality. You’re helpless here with shared hosting, but with cloud, the resource is readily available and the client can access it easily.
Performance & Security
Cloud hosting offers the best solutions for the performance and security of your Laravel apps .
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 remain unaffected.
Similarly, cloud hosting comes with better security features like firewalls, IP whitelisting, etc.
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 computing services and Amazon Simple Storage Service (S3) and Amazon Glacier for storage. Google offers its Google Compute Engine (GCE) and Google Cloud Storage for enterprises. Digital Ocean, Linode, and Vultr also provide reliable cloud hosting services.
You Might Also Like: What Should you know About AWS EC2 Hosting Server
All these cloud hosting platforms offer distinctive features and hosting plans. 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. To run organizational operations more efficiently, Most companies are now turning to “managed” cloud hosting services to run their organizational operations efficiently.
Managed Cloud Hosting with Cloudways
If you type the phrase ‘managed cloud hosting’ in Google’s search bar, you see a long list of hosting providers that claim to manage your application and server without any hassle. However, tere is a Catch-22 here.
While looking for a managed cloud hosting platform, you must check the provider’s features. They must be reliable, efficient enough, user-friendly, and affordable. I know that it’s not easy to pick the right option from a list of hosting providers, including GoDaddy, BlueHost, and many others. There are numerous hosting providers like Bluehost alternative and cPanel alternative that you can choose to buy faster hosting from them.
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 the smooth and optimized performance of the Laravel application, Cloudways provides an optimized stack with the 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 the Laravel 9 and PHP 7.4-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.
To get started with Cloudways, you have to select your Laravel application version, for instance, Laravel 9, and submit all application details.
Then select your cloud hosting server. You can also change your server size according to your clients’ requirements.
In the Application Management tab, you can find many other features like Security, Deployment via Git, Cron job Management, Application Settings, and CloudFlare CDN.
Cloudways also provides Free SSL certificates and lets you 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 the 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, 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.
Stop Wasting Time on Servers
Cloudways handle server management for you so you can focus on creating great apps and keeping your clients happy.
What Do 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 have to.. Every project has its own needs, but you will always find a VPS useful. 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…
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 down file 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 then change my APP_ENV to “local” inside my .env.
“That or you can use good old’ 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. There are libraries out there (like Voyager) that make shared hosting + Laravel manageable though, so I wouldn’t worry.”
Speaking from personal experience. I tried to cheap out and host my Laravel app on shared hosting. You will face several 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 cheap, and setting up everything is a breeze just follow the documentation.
Developers and agencies are still using Laravel shared hosting services due to many reasons, mainly low client budgets or low security and backup requirements.
In this article, I have elaborated in detail onthe disadvantages you face when you deploy the Laravel app on a shared hosting server. Instead, you must opt for a managed cloud hosting server foryour Laravel apps to reap the unprecedented benefits in the long run.
Q: How to solve the 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 a file to the storage folder:
chmod -R o+w laravel/storage
Here, Laravel is the name of the directory where the application is installed.
Q: How to deploy Laravel on shared hosting
A: Laravel shared hosting deploy
- Remove the public from the URL.
- Export database from the local environment.
- Do ZIP your Laravel project.
- Create a database in your cPanel.
- Import the local exported database into the shared hosting database.
- Upload project ZIP file to public_html folder and extract.
- Update database details into the config file.
- Some security setup.
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 can function properly and get the required bandwidth and speed. Web servers like Apache, NGINX, and other speed optimization tools always come in pretty handy in enhancing app performance.
Customer Review at
“Cloudways hosting has one of the best customer service and hosting speed”
Sanjit C [Website Developer]
Shahzeb is a Digital Marketer with a Software Engineering background, works as a Community Manager — PHP Community at Cloudways. He is growth ambitious and aims to learn & share information about PHP & Laravel Development through practice and experimentation. He loves to travel and explore new ideas whenever he finds time. Get in touch with him at [email protected]