How to Host a Website on a Server: Complete Step-by-Step Guide

Hosting a website on a server is a key step in its creation and publication. This article provides a detailed step-by-step guide on how to set up a website on a server from scratch.

Step 1: Preparing the Server

Before installing the website, you need to prepare your server. First, decide on the server type:

  • Shared Hosting — a simple option for small sites,

    no configuration required.

  • VPS/VDS — a flexible and powerful option for sites with higher demands.

  • Dedicated Server — for large projects needing full configuration control and maximum performance.

This guide covers how to install a website on a VDS.

If you have a control panel (like FastPanel, ISPmanager, or Plesk), it will simplify the setup. Otherwise, you'll need to configure everything manually via the command line.

Step 2: Installing Web Server, PHP, and Database

Most websites require a web server (e.g., Apache or Nginx), PHP, and a MySQL or MariaDB database.

For Ubuntu/Debian:

apt update && apt upgrade -y

apt install apache2 php php-mysql mysql-server unzip curl -y

For CentOS/RHEL:

yum update -y

yum install httpd php php-mysqlnd mariadb-server unzip curl -y

After installation, start and enable the services:

systemctl start apache2 # For Apache on Ubuntu/Debian
systemctl start httpd # For Apache on CentOS/RHEL

systemctl enable apache2
systemctl enable httpd

systemctl start mysql
systemctl enable mysql

Step 3: Database Setup (if applicable)

Once MySQL or MariaDB is installed, you need to create a database and a user for your site.

Connect to MySQL:

mysql -u root -p

Inside MySQL, run the following:

CREATE DATABASE mysite_db;

CREATE USER 'mysite_user'@'localhost' IDENTIFIED BY 'strong_password';

GRANT ALL PRIVILEGES ON mysite_db.* TO 'mysite_user'@'localhost';

FLUSH PRIVILEGES;

EXIT;

Step 4: Uploading and Installing the Website

  1. Upload your site files to the server using SFTP/FTP (e.g., FileZilla) or scp:

scp site.zip root@IP:/var/www/html/

  1. After uploading, unzip the archive:

cd /var/www/html/

unzip site.zip

  1. Ensure files have the correct ownership and permissions:

chown -R www-data:www-data /var/www/html/

chmod -R 755 /var/www/html/

Step 5: Domain Binding

Once the website is uploaded, bind your domain:

  1. Register a domain with a domain registrar.

  2. Set the A-record in your domain’s DNS to point to your server’s IP.

  3. Wait 5 to 30 minutes for DNS propagation.

Step 6: SSL Installation (HTTPS)

To ensure security, it’s recommended to install an SSL certificate. One of the most popular and free options is Let’s Encrypt.

Installing SSL via Let’s Encrypt:

For Ubuntu/Debian:

apt install certbot python3-certbot-apache -y

certbot --apache

Follow the instructions to complete the certificate setup for your domain.

Step 7: Testing

After completing the server and domain configuration, open your browser and enter your site’s address, for example, https://example.com.

Ensure the site loads correctly without errors. Also, check database connections and necessary services.

If your site uses a CMS (like WordPress, Joomla, OpenCart, etc.), simply download the archive from the official site and upload it to your server. Then follow the CMS setup wizard in your browser.

Conclusion

Installing a website on a server isn’t complicated if you follow the steps. Proper server configuration, database setup, file upload, and domain binding — all these steps will help you successfully publish your website online. You can use a control panel to simplify the process or set up the server manually for more flexibility.

If you encounter issues during installation or need help configuring your server, the DiorHost team can provide administrative assistance. You can request support via a ticket on their website or via Telegram technical support.