Skip to content

How to deploy a website live: A tutorial for new developers

Every developer will at some point have to deploy their first website to a live server.  This helpful guide will talk about the deployment process and guide you in publishing your first website to the internet, from purchasing your domain name to deploying your code live.

Recently on Reddit I came across a post by a new developer who had landed his first freelance client.  He had experience in web development but never actually deployed a website live by himself.  While it may seem strange that a web dev doesn’t know how to actually make a website live, it is actually pretty understandable, since the deployment process can actually fall under the umbrella of dev-ops instead of web development.  That is, the people responsible for coding the websites may not be the one deploying it live.  This can be especially true in larger organizations that have a dedicated individual or team dedicated to server and deployment operations.

This guide will help you understand the web hosting and deployment process, from configuring your domain name to actually getting your code live.  This guide assumes that you have a website or web app that is ready to go live and that it runs on your local machine.

First Thing’s First: What type of host do you need?

The type of web host you use will depend on what you need to host.  Static files, such as HTML, CSS and JS can be hosted pretty much anywhere since they don’t need any compilation or other language interpreter, the browser handles all that so a basic HTTP web server will work fine for those.

However, when you want to run something more dynamic, like a PHP app such as WordPress or Laravel, or an app written in Node JS, you need a host that has the required prerequisite software installed on the server.  You’ll find that some languages are more supported than others.  For instance, if you’re running a PHP / MySQL web app, there are probably a million different web hosts you can choose from since that stack is very well supported.  However, something like Node JS is not as well supported, so your hosting options become more limited.

It’s important that you find a host that supports your software stack, or barring that, allows you to install it yourself, but more on that later.

How hard do you want the process to be?

There are different levels of difficulty you can pick from when trying to get your website or web app live on hosting.  The tradeoff is that the more difficult it is to your host your web app, the more control you will have over the experience.

For instance, the easiest option and the one you should probably go with as a beginner is managed hosting.  This is where a web host manages all of the server configuration and software installation for you.  This is a great option if you don’t want to worry about server setup and security, but can be limiting if you need to run some software that isn’t in wide adoption or isn’t a part of your host’s standard package.  Managed hosting typically gives you access to your website via a Control Panel where you can change settings easily and you also will get SFTP access to upload files.  If you’re lucky, you might also get limited SSH access where you can run some developer tools like Git and Composer, but that isn’t a given with managed hosting.

The alternative to managed hosting is hosting you manage yourself.  To get this level of control you typically need to purchase what is called a VPS or Virtual Private Server.  Here, you get full control over the server, but that can be a double edged sword.  With a self-managed VPS, you are responsible for installing all the software yourself.  Some VPS servers come with a pre-installed template of software installed to help you out, but you can also get a VPS server that has nothing installed out of the box except the operating system and a SSH connection.  This will all depend on your host and the package and image that you chose to get started.

A VPS gives you ultimate control, but that means you are ultimately in control.  You’re on your own for security, so don’t mess it up and make sure to install all of your software updates in a timely manner.

There are also hosts who offer a managed VPS, which is sort of a mix between managed hosting and unmanaged VPS hosting.  You get a VPS and the ability to install software on it, but your web host also has access to the VPS and will install updates and security patches for you.  You can also ask your host to install specific software or offer technical support.  Managed VPS servers often also come with a control panel installed to make management easier.  Depending on your use case, a managed VPS might be the best option if you need a non-standard software stack but don’t want to worry about securing your own server.

Available Control Panels for Web Hosting

Unless you want to manage everything via the command line, you’re going to want a control panel to manage your hosting account.  If you chose managed hosting, your host will almost certainly include a control panel with your hosting package.  If you chose a VPS server, however, you may not get a control panel or you may be able to pick your control panel.  With managed hosting the control panel is almost always included for free with the hosting, but with a VPS if you want a control panel it will almost always cost extra.

There are several popular control panels you may encounter in the wild, but the most common by far is CPanel.  CPanel is the industry standard as far as control panels and you’ll see it installed on the majority of PHP based web hosts.  Other control panels you might come across on hosts include DirectAdmin and Enhance.  Having used each of these panels, I personally find Enhance the easiest to use, but CPanel and DirectAdmin are also great control panels and all have similar functionality.

For instance, within your control panel you’ll be able to create a database, manage domains, configure email accounts and maybe even change some server settings such as your PHP version.  The level of access you will have depends on the control panel you’ve chosen as well as whether you are on managed hosting or on a VPS.  Typically managed hosting is a lot more locked down than a VPS will be.

If you are a beginner to web hosting, I highly recommend ensuring that your hosting comes with a control panel of some form as managing everything via a terminal will not be fun.  Some hosts might also provide a proprietary control panel, which is ok, but you’ll typically have more options with one of the established panels previously listed.

Pointing your domain name at your web hosting

The first thing you want to do when deploying a website live is to point your domain name at your server.  Sometimes, it might take a few hours or even a day or so for your domain to point at your hosting due to lags in DNS as your changes propagate to the rest of the world, so getting a jump on this step can help minimize this delay, along with lowering the Time to Live (TTL) values on any domain records you may have.

If you don’t have a domain, you’ll need to use a domain registrar to purchase a domain name.  There are tons of registrars, but the one I use is Namecheap.  You will need to update your domain to point to your web hosting by updating the DNS records of your domain at your domain registrar.

This process varies based on where you bought your domain, but typically involves you updating your domain to point to the nameservers of your web hosting.  Typically your web host will provide you with nameservers to use and may look something like ns1.yourwebhostdomain.com and ns2.yourwebhostdomain.com.  You’ll want to update your domain at your register to point to these nameservers, which will point visitors to your domain to your web server.  You’ll also want to make sure you add your domain inside of your control panel if your host hasn’t already done this for you.

On rare occasions you may not be updating nameservers but instead may be pointing your domain directly at an IP address.  This is typically done with an A Record on your domain.  With nameservers, if the IP address of your server changes, your domain updates automatically, but with an A Record, if your server’s IP updates you’ll manually have to update your domain to point to the new IP address to keep your website online.

Once your domain is pointed at your server, you should now see either a 404 page, a 403 page, a directory listing or a welcome page.  What you see will depend on your server configuration and any customizations your web host may have made to the server.  As long as you’re not seeing the default screen shown for your domain from your domain registrar though, you should be in good shape to proceed.

Prepping your hosting for your website

Before you deploy your website live, there’s a few things you might want to do.  For instance, you might need to create a database for your application.  Depending on the control panel you have, this process will vary, but typically involves using a wizard to set a database name, user and password.  Then you will usually have the option to upload a SQL file, either via a dedicated upload button or via the database management program PHPMyAdmin.

Some web hosts may also offer the ability to remotely access your MySQL database, either via allowing a specific IP address via the control panel or via a SSH tunnel.  However, this is not always something that works and even if your control panel does have an option to whitelist an IP, your host’s firewall may still block remote access, so your mileage may vary.

You may also want to create an email account on your hosting before going live.  This can be especially necessary if your application sends email.  The default PHP mailer installed on many hosts is often blocked as spam by email services like Gmail, so you’ll want to create a mail relay email account to send emails from your application.  To do this, make a new email account in your control panel, then ensure your application can connect to this email account via SMTP to send transactional emails.

Time to Go Live: Getting Your Code on the Server

Ok, so you’ve done all your setup, your domain’s all set and you’re ready to go live.  The final step is to get your code on the server.  Assuming that your server is ready to run the code, this should be a pretty simple process and you have a few options.

The first option is good old Secure FTP, or SFTP.  If your host only offers FTP and not SFTP, that’s not a good sign, as FTP sends your credentials over the internet in cleartext.  However, SFTP securely encrypts your credentials.  To upload your files with SFTP, you’ll need a compatible program like Filezilla or WinSCP to upload your files.  Simply connect to your server and upload your files to the public_html folder.  If you don’t have a public_html folder, look for another folder like www on the server that you can access.  Simply upload your files to the server and update your config file with any relevant information such as domain or database and you should be good to go.

The second option, which is more complex but makes things easier in the long run, is to get your code via Git.  For instance, you may want to store your code in a Github repo and push or pull that code directly to your server.  Some control panels like CPanel make this easy with built in Git Integration.  Others, like Enhance, don’t have built in Git integration, but allow you to use SSH to manually run git clone and git pull commands.

If you’re using a manual pull via SSH, you’ll need to add a deploy key in Github so you can pull changes from your repo into your server.  Typically you’ll want to generate a new SSH key on your server, then upload that to Github.

If you find that your server complains when trying to connect to Github, you may need to add Github to your server’s known SSH hosts using this command:

ssh-keyscan -H github.com >> ~/.ssh/known_hosts

Whether you choose SFTP or Git integration, if you did everything correctly your web app should now be live!  If things don’t work right out of the box, you may need to do some tweaking, such as ensuring that your database credentials are set correctly or tweaking other server settings such as paths or PHP version.  Don’t be afraid to reach out to your host for support.

If you’re not sure where to host your web app, one host that we recommend is MediaServe.  For hosting PHP web apps like WordPress and Laravel, they’re awesome.  They give you the Enhance control panel and have containerized hosting, meaning that even though you’re on a shared hosting environment, your website is isolated from all others on the server since it has its own dedicated container.  This also means you get access to developer tools such as Git and Composer which come in handy when working with advanced tools like Bedrock and Sage 10 for WordPress.

Additional Resources

Do you need more help in deploying your web app?  We offer mentorship for developers who want to learn more about web development.  We can help you understand the deployment process and guide you every step of the way.  Sound cool?  Schedule a free consultation with us today!

Leave a Reply

Your email address will not be published. Required fields are marked *