When it comes to deploying web applications, the choice of hosting is pretty crucial. It can significantly affect your application’s performance, scalability, and, most importantly, the costs involved.
What if you’re working on a small, personal project? Or on a project for a small local community, in which you don’t want to, or cannot invest a lot of money? What if you just want a simple bare-metal server to host your application, with a simple, straightforward pricing plan?
At the time I wanted to deploy my small website, written in Laravel, these were the questions that came to mind: how do I host my web application, and how much is that going to cost me? After some digging and asking, I found out that the best hosting options available for me were: shared hosting, a virtual private server (VPS), or my old PC. Since I didn’t want to use my old PC, because it has like 1 GB RAM of memory, I did some research into shared hosting and VPS servers. Before explaining why I chose to deploy the website on Contabo, let’s have a look at what each type of deployment server is and can be used for:
Understanding Your Hosting Options
-
Shared Hosting
Ideal for small websites or blogs with low traffic, shared hosting is where your website resides on the same server as many others, sharing resources like CPU, RAM, and disk space.
-
Virtual Private Server (VPS)
A step above shared hosting, VPS provides a virtualized environment with allocated resources. It’s a cost-effective solution for medium-sized businesses requiring more control and better performance.
As mentioned previously, I chose to go with a VPS server. Additionally, here are a few more hosting options, along with examples of providers:
3. Dedicated Servers
For websites with high traffic and those requiring ultimate control and performance, dedicated servers offer a physical server with dedicated resources.
4. Cloud Hosting
Cloud hosting offers scalable resources on demand, making it perfect for applications with fluctuating traffic. It provides high availability and flexibility in managing your resources.
5. Managed Hosting
Managed hosting takes the hassle out of server management, offering a dedicated or cloud server with added services like maintenance, security, and software updates.
6. Platform as a Service (PaaS) and Infrastructure as a Service (IaaS)
For developers focused on building without managing the underlying infrastructure, PaaS and IaaS provide environments to develop, host, and scale applications with ease.
My Journey: Deploying on Contabo
I really wanted to have a server in which I have admin rights, and I can install any software that I want, so I opted for a VPS. I’ve decided to get one from Contabo. For around $5, I’ve got 4 vCPU Cores, 6 GB RAM, 400 GB SSD, 1 Snapshot, and 32 TB Traffic. The server’s operating system can be Linux-based: Ubuntu, CentOS, Debian, or it can be Windows.
The actual deployment process is pretty straightforward, but before diving into it, let’s talk about buying a domain for your website.
To make your website accessible via a human-readable address on the internet, you’ll need to rent a domain from a Domain name registrar. Since Contabo is also selling domain names, I would suggest buying the domain name from them. The reason behind this is that, if you buy it from another Domain name registrar, it may be more complicated to configure your website with Contabo if your domain is registered elsewhere, potentially requiring a domain transfer for easier management. This just adds extra hassle, and you can only move a domain from one registrar to the other after a certain period of time from the day you bought the domain name. So, with that out of the way, let’s continue with the actual deployment process.
Deploying Laravel on Contabo
Now, let’s dive into the actual deployment process.
First things first: connecting with SSH to the server that you’ve just bought. In your terminal, you can run ssh -lroot -p22 YOUR_IP_ADDRESS. You can find your ip address in your account dashboard, under the VPS control section. After the command is executed, we need to input the password, the same password that Contabo asked for when you bought the server:
Once you’re logged in, you can just clone your Git repository, and have the code of the application on the deployment server.
Since you have a whole server with admin rights just for yourself, you can install whatever software you want. I went with Nginx as a web server, MySQL for databases and installed PHP 8.3 locally. And, with this, you’re pretty much done.
Final Thoughts
Deploying a web app can be quite tricky, when you take into consideration more than just what technology will help you, but also its price, and your budget, especially if this is your first time deploying one.
I hope this article has informed you about the different options you have for hosting, made you aware of the benefits of having the server and the domain from the same provider, and given you the courage needed to deploy your web app on the internet.