What’s a website worth when it’s not hosted anywhere? That’s right, nothing!
In this tutorial I’ll cover the topics on how to host a website from start to finish.
Who am I to tell you how to host your site? Well, I approximattely developed and published around 150 sites in my 3-year carreer, so let’s say I’m used to it by now. 😉
What is a web host?
Since you already have a website ready, you should already know your website exists out of a bunch of files. A web host is a server that will store your files and serve them to the client (the browser).
A web host might also be in control of your database hosting, a database is commonly used to store data and allows your backend to be more dynamic.
Where can I find such
There are three common types of hosting, dedicated hosting, shared hosting and cloud hosting.
- Dedicated hosting: Expensive with high performance
- Shared hosting: Usually cheap with shared resources
- Cloud hosting: More expensive than shared hosting, but will perform better
I won’t discuss the hosting companies in this article, here’s an article that explains all of the hosting companies with their befenefits.
- Choose a hosting company where the server is as close to your business as possible
- Look for great support, do they have a live chat for example? What’s their response time?
- The platform they provide to you, is it easy to use?
How to connect to your web host
Usually when you subscribe to your hosting company you will receive an email with a summary of your order and instructions on how to connect with your host.
Connections are usually made with either (S)FTP or SSH, where SFTP uses the same credentials as your SSH user.
You should always use SFTP or SSH whenever possible, its connection is encrypted wher
as standard FTP connection is not.
A great tool for using these protocols is FileZilla, a free tool for managing SFTP connections and transferring files to your server, it works both for Mac and Windows.
Connect with your host and transfer your files in the public directory on your host. The public directory is usually named www or public_html depending on your host.
To learn how to automatically publish your files with Git, read automatic website deployment of any site with Gitlab.
Create and connect with your database
Now that your files are transfered on your host, it’s time we create and connect your database to your website.
Creating the database really depends on your host, but you’ll have to create a database with a given database name, and a database user with a username, password and rights to control the database your created.
Once you created your database, you should receive a hostname, on most hosting providers this would be localhost and port which usually is 3306.
Upload your existing database structure and data to the new database, you can export using mysqldump or phpmyadmin for this, or any db software of your choice. Importing online usually works with phpmyadmin.
The last step is to connect your website files to your database, depending on the framework/cms you use there are different ways to do this. Usually there’s a config file or .env file.
Connect your custom domain name
Since you don’t want users to visit your website by giving them an IP address, that would be dumb 😛 You should connect your own domain to your new web hosting.
Don’t have a domain yet? Register them with a domain registrar such as namecheap.com or versio.nl. Different Domain name extensions have different prices, make sure you look for decent prices, usually the prices are around 8-15€ yearly.
The linking of your domain with your hosting is done with DNS records, you should be able to manage your DNS records on your domain registrar, if not you should point your nameservers to your hosting package and manage them over there.
The right setup for your DNS should be to link your domain with an A-record to your IP address of your hosting package.
So if your IP-address is: 126.96.36.199 you should link your root domain-name with an A-record to 188.8.131.52:
yourdomain.com A 184.108.40.206
Of course, if they visit www.yourdomain.com you’d want it to work as well, you could link your A record the same way, or you could setup a CNAME record:
www.yourdomain.com CNAME yourdomain.com
Changing any of these records might take time to persist to your network/pc. DNS is heavily cached on both your network and your provider’s or even deeper for performance reasons. So depending on your DNS settings on your pc it might take longer to notice new changes.
To test your hosting right away, you can edit your hosts file, this works both for Windows and for Mac:
For Windows: C:\Windows\System32\drivers\etc
For Mac: /etc/local/hosts
Add the following:
220.127.116.11 yourdomain.com www.yourdomain.com
Testing and finishing touches
Well you’re basically done now, the only thing you’ll need is to test everything so it works.
Things you need to test:
- Is you debug mode off?
- Does your contact form work?
- Is your website speed normal? If it isn’t, check if you can enable caching on your website host
- Check if you can upload images, usually fixable by change permissions or post max within the PHP.ini settings.
- Link Google Analytics
- Link Google webmaster tools
- Add a reCAPTCHA on your form to prevent spam
- Create a sitemap, and submit your sitemap to webmaster tools.
If you run in to some kind of trouble, or I helped your with this tutorial feel free to comment below. I’ll be around!