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.
- 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 Cloud Hosting?
- 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 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.
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
Laravel Hosting Made Simple
Experience fast performance with 24/7/356 support.
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 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. 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 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
On shared hosting, unexpected web traffic could affect the server’s limited bandwidth resources. This will ultimately result in a 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 incurred in the future.
For a Laravel application to work smoothly, the 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 the Laravel app on shared hosting servers.
SSH or Command Terminal
You must know that 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 to work with. You can work with FTP only.
Most of the developers remain highly critical and discourage the deployment of the Laravel app via FTP. Moreover, if there is no SSH Terminal available, you won’t have any access to the composer, artisan, or any other command-line tools to work with.
If you are using 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 that there is no application backup facility available. If the data is lost, it’s lost forever. Therefore, shared hosting is not an 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 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 the server setup.
Laravel Shared Hosting Deploy Process
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 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 maybe 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 not affect 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 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 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 of the companies are now turning to managed cloud hosting services. ‘Managed’ is the keyword 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 a 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. Also see bluehost alternative.
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.
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 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 the 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 the 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 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.
Laravel Hosting Made Simple
Experience fast performance with 24/7/356 support.
What Do 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 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.
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 its a breeze just follow the documentation.
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 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 URL.
- Export database from the local environment.
- Do ZIP your Laravel project.
- Create a database in your cPanel.
- Import the local exported database into 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 could get the required bandwidth and speed to function properly. Web servers like Apache, NGINX, and other speed optimization tools always come pretty handily in enhancing app performance.
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 fewer requirements about security and backup.
In this article, I have elaborated in detail about the different disadvantages you face when you deploy the Laravel app on a 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.
Customer Review at
“Cloudways hosting has one of the best customer service and hosting speed”
Sanjit C [Website Developer]