Tutorials Logic
Tutorials Logic, IN info@tutorialslogic.com
Navigation
Home About Us Contact Us Blogs FAQs
Tutorials
All Tutorials
Services
Academic Projects Resume Writing Website Development
Practice
Quiz Challenge Interview Questions Certification Practice
Tools
Online Compiler JSON Formatter Regex Tester CSS Unit Converter Color Picker
Compiler Tools
Hosting Guide

How to Host a Website — From Basic to Advanced

A complete step-by-step guide to hosting your website — from choosing a domain and hosting plan to VPS setup, SSL, CI/CD deployment, CDN, and advanced security hardening.

Beginner Friendly VPS & Cloud SSL & HTTPS CI/CD Deploy Security
Published: Apr 2026 Updated: Apr 2026
⭐ Recommended Hosting
Get Started with Hostinger
Reliable, fast, and affordable hosting — perfect for beginners and professionals alike. Plans start at just ₹69/mo.
Get Hosting Now

What is Web Hosting?

Web hosting is a service that stores your website files on a server and makes them accessible to anyone on the internet. When someone types your domain name into a browser, the DNS system routes the request to your hosting server, which then serves your website files back to the visitor.

Think of it like renting space on a computer (server) that is always on, always connected to the internet, and serves your website 24/7.

Types of Web Hosting

Shared Hosting
Multiple websites share the same server resources. Cheapest option. Best for small websites, blogs, and beginners. Limited performance under high traffic.
₹69–₹299/mo
VPS Hosting
Virtual Private Server — dedicated resources on a shared physical machine. Full root access, better performance. Best for growing websites and developers.
₹499–₹2000/mo
Dedicated Server
An entire physical server for your website. Maximum performance, full control. Best for high-traffic enterprise applications.
₹5000+/mo
Cloud Hosting
Resources spread across multiple servers. Highly scalable, pay-as-you-go. Best for apps with variable traffic spikes.
₹300–₹3000/mo
Managed WordPress
Hosting optimized specifically for WordPress. Automatic updates, backups, and security. Best for WordPress sites without technical management.
₹199–₹999/mo

1 Step 1 — Choose a Domain Name

Your domain name is your website's address on the internet (e.g., tutorialslogic.com). It's the first thing visitors see, so choose wisely.

Tips for Choosing a Domain Name

Keep it short & memorable — Aim for under 15 characters. Avoid hyphens and numbers.
Use keywords — Include your niche or brand name. Helps with SEO and brand recognition.
Choose the right extension.com is most trusted. Use .in for India, .org for non-profits, .io for tech startups.
Check availability — Use a registrar to check if your desired name is available. Also check social media handles.
Avoid trademark issues — Don't use brand names or trademarked terms in your domain.

Popular Domain Extensions

.com — Commercial (most popular) .org — Organizations .net — Networks .io — Tech startups .in — India .co — Company/Colombia .dev — Developers .app — Applications

Popular Domain Registrars

Hostinger — Affordable, bundles with hosting
GoDaddy — Largest registrar worldwide
Namecheap — Budget-friendly, free WhoisGuard
Google Domains — Simple, transparent pricing
BigRock — Popular in India

2 Step 2 — Choose a Hosting Provider

Your hosting provider determines your website's speed, uptime, security, and scalability. Here's a comparison of the main hosting types to help you decide:

Feature Shared VPS Cloud Dedicated
Price₹69–299/mo₹499–2000/mo₹300–3000/mo₹5000+/mo
PerformanceLow–MediumMedium–HighHighVery High
ControlLimited (cPanel)Full root accessFull accessFull access
ScalabilityLowMediumVery HighLow (fixed)
Best ForBeginners, blogsDevelopers, appsVariable trafficEnterprise
Technical SkillNone requiredIntermediateIntermediateAdvanced
Recommendation for Beginners: Start with Shared Hosting. It's affordable, easy to manage via cPanel, and sufficient for most small websites and blogs. Upgrade to VPS when you need more control or performance.
Ready to get hosting?
Hostinger offers reliable shared, VPS, and cloud hosting at unbeatable prices. Free domain + SSL included.
Visit Hostinger

3 Step 3 — Buy Hosting & Connect Your Domain

Once you've purchased hosting, you need to connect your domain to your hosting server. This is done by updating the nameservers at your domain registrar to point to your hosting provider.

How to Update Nameservers

  1. Log in to your domain registrar (e.g., GoDaddy, Namecheap, Hostinger)
  2. Go to DNS Management or Nameservers section
  3. Replace the existing nameservers with the ones provided by your hosting company
  4. Save the changes and wait for DNS propagation (24–48 hours)

Example Nameservers (Hostinger)

Nameservers
ns1.dns-parking.com
ns2.dns-parking.com

# Or for Hostinger:
ns1.hostinger.com
ns2.hostinger.com
DNS Propagation: After updating nameservers, it can take 24–48 hours for changes to propagate worldwide. During this time, some visitors may see the old site and others the new one. Use dnschecker.org to monitor propagation.

4 Step 4 — Upload Your Website

There are three main ways to upload your website files to your hosting server. Choose the method that best fits your workflow.

Method 1: FTP/SFTP with FileZilla

FTP (File Transfer Protocol) and SFTP (Secure FTP) let you transfer files between your computer and the server. FileZilla is the most popular free FTP client.

FileZilla Connection Settings
# FileZilla Quick Connect Settings
Host:     ftp.yourdomain.com   (or your server IP)
Username: your_ftp_username    (from hosting control panel)
Password: your_ftp_password
Port:     21 (FTP) or 22 (SFTP - recommended)

# After connecting, navigate to:
# Remote: /public_html/  (or /www/ depending on host)
# Local:  Your website folder on your computer

# Drag and drop files from left (local) to right (remote)

Method 2: cPanel File Manager

Most shared hosting plans include cPanel, which has a built-in File Manager. No software installation needed.

  1. Log in to your hosting cPanel (usually at yourdomain.com/cpanel)
  2. Click File Manager under the Files section
  3. Navigate to public_html folder
  4. Click Upload and select your website files
  5. If uploading a ZIP file, right-click and select Extract

Method 3: Git Deploy via SSH

For VPS or cloud hosting, you can deploy directly from a Git repository via SSH. This is the most professional approach.

Terminal (SSH)
# SSH into your server
ssh username@your-server-ip

# Navigate to web root
cd /var/www/html

# Clone your repository
git clone https://github.com/yourusername/your-repo.git .

# Or pull latest changes if already cloned
git pull origin main

# Set correct permissions
chmod -R 755 /var/www/html
chown -R www-data:www-data /var/www/html

5 Step 5 — Configure SSL/HTTPS

SSL (Secure Sockets Layer) encrypts data between your server and visitors' browsers. HTTPS is now a ranking factor for Google and is required for user trust. Modern browsers show a "Not Secure" warning for HTTP sites.

Why HTTPS Matters

Security — Encrypts all data in transit
SEO Boost — Google ranks HTTPS sites higher
Trust — Padlock icon builds visitor confidence
HTTP/2 — Faster loading with HTTP/2 protocol

Install Free SSL with Let's Encrypt (VPS)

Terminal (Ubuntu/Debian)
# Install Certbot (Let's Encrypt client)
sudo apt update
sudo apt install certbot python3-certbot-nginx -y

# Obtain and install SSL certificate for Nginx
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

# For Apache
sudo apt install python3-certbot-apache -y
sudo certbot --apache -d yourdomain.com -d www.yourdomain.com

# Auto-renewal (runs twice daily via cron)
sudo certbot renew --dry-run

# Check renewal timer
sudo systemctl status certbot.timer

Enable SSL via cPanel (Shared Hosting)

  1. Log in to cPanel → Security section
  2. Click SSL/TLS or Let's Encrypt SSL
  3. Select your domain and click Issue Certificate
  4. Wait 1–2 minutes for the certificate to be issued
  5. Enable Force HTTPS Redirect in cPanel or via .htaccess

6 Step 6 — Point Domain to Hosting (DNS Records)

DNS (Domain Name System) translates your domain name into an IP address. You need to configure DNS records to point your domain to your hosting server.

Common DNS Record Types

Record Purpose Example
AMaps domain to IPv4 addressyourdomain.com → 192.168.1.100
AAAAMaps domain to IPv6 addressyourdomain.com → 2001:db8::1
CNAMEAlias one domain to anotherwww → yourdomain.com
MXMail server recordsmail.yourdomain.com
TXTText records (SPF, DKIM, verification)v=spf1 include:hostinger.com ~all
NSNameserver recordsns1.hostinger.com

Example DNS Configuration

DNS Zone File
# A Record - point root domain to server IP
@       IN  A       203.0.113.10

# A Record - point www subdomain to server IP
www     IN  A       203.0.113.10

# CNAME - alternative: alias www to root
www     IN  CNAME   yourdomain.com.

# MX Record - email server
@       IN  MX  10  mail.yourdomain.com.

# TXT Record - SPF for email authentication
@       IN  TXT     "v=spf1 include:hostinger.com ~all"

7 Step 7 — Test Your Website

Before announcing your website, run through this comprehensive checklist to ensure everything works correctly.

SSL Certificate Active
Visit your site with https:// — you should see a padlock icon. Test at SSL Labs.
Page Speed
Test with Google PageSpeed Insights. Aim for 90+ on desktop, 70+ on mobile.
Mobile Responsiveness
Use Google Mobile-Friendly Test and check on real devices.
Broken Links
Use W3C Link Checker or browser extensions to find 404 errors.
Cross-Browser Testing
Test in Chrome, Firefox, Safari, and Edge. Use BrowserStack for comprehensive testing.
Forms & Contact
Submit all forms and verify emails are received. Check spam filters.
404 Error Page
Visit a non-existent URL to confirm your custom 404 page displays correctly.
Uptime Monitoring
Set up free uptime monitoring with UptimeRobot to get alerts if your site goes down.

Advanced: VPS Server Setup from Scratch

If you're using a VPS, you'll need to configure the server yourself. Here's a complete setup guide for Ubuntu 22.04 LTS with Nginx.

1. Initial Server Login via SSH

Terminal
# Connect to your VPS via SSH
ssh root@your-server-ip

# Or with a specific key file
ssh -i ~/.ssh/my-key.pem root@your-server-ip

# First thing: update the system
apt update && apt upgrade -y

# Create a non-root user (security best practice)
adduser deploy
usermod -aG sudo deploy

# Switch to new user
su - deploy

2. Install Nginx Web Server

Terminal (Ubuntu)
# Install Nginx
sudo apt install nginx -y

# Start and enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx

# Check status
sudo systemctl status nginx

# Test Nginx config
sudo nginx -t

# Reload after config changes
sudo systemctl reload nginx

3. Configure Nginx Virtual Host

/etc/nginx/sites-available/yourdomain.com
server {
    listen 80;
    listen [::]:80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/yourdomain.com/public_html;
    index index.html index.php;

    location / {
        try_files $uri $uri/ =404;
    }

    # PHP support (if needed)
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    }

    # Deny access to .htaccess
    location ~ /\.ht {
        deny all;
    }

    # Gzip compression
    gzip on;
    gzip_types text/plain text/css application/json application/javascript;
}

# Enable the site
# sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
# sudo nginx -t && sudo systemctl reload nginx

4. Configure UFW Firewall

Terminal
# Install UFW (usually pre-installed)
sudo apt install ufw -y

# Allow SSH (IMPORTANT: do this before enabling UFW)
sudo ufw allow OpenSSH

# Allow HTTP and HTTPS
sudo ufw allow 'Nginx Full'

# Enable firewall
sudo ufw enable

# Check status
sudo ufw status verbose

# Block a specific IP (if needed)
sudo ufw deny from 192.168.1.100

5. Deploy a Node.js App with PM2

Terminal
# Install Node.js (via NodeSource)
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt install nodejs -y

# Install PM2 process manager globally
sudo npm install -g pm2

# Start your app
pm2 start app.js --name "my-app"

# Start with ecosystem file
pm2 start ecosystem.config.js

# Save PM2 process list (survives reboots)
pm2 save
pm2 startup

# Monitor processes
pm2 status
pm2 logs my-app
pm2 monit

6. Deploy a PHP App (Laravel/CodeIgniter)

Terminal
# Install PHP 8.1 and extensions
sudo apt install php8.1 php8.1-fpm php8.1-mysql php8.1-curl \
  php8.1-mbstring php8.1-xml php8.1-zip php8.1-gd -y

# Install Composer
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

# Clone your PHP app
cd /var/www
sudo git clone https://github.com/yourusername/your-php-app.git yourdomain.com
cd yourdomain.com

# Install dependencies
composer install --no-dev --optimize-autoloader

# Set permissions
sudo chown -R www-data:www-data /var/www/yourdomain.com
sudo chmod -R 755 /var/www/yourdomain.com
sudo chmod -R 775 /var/www/yourdomain.com/writable  # CodeIgniter

# Copy and configure .env
cp .env.example .env
nano .env  # Edit database credentials etc.

Advanced: CI/CD Deployment with GitHub Actions

CI/CD (Continuous Integration / Continuous Deployment) automates the process of testing and deploying your code every time you push to GitHub. This eliminates manual deployments and reduces human error.

How It Works

Push Code
Run Tests
Build
Deploy
Live!

GitHub Actions Workflow: Deploy to VPS via SSH

Create this file at .github/workflows/deploy.yml in your repository:

.github/workflows/deploy.yml
name: Deploy to Production

on:
  push:
    branches:
      - main  # Trigger on push to main branch

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js (if needed)
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install dependencies
        run: npm ci

      - name: Run tests
        run: npm test

      - name: Build project
        run: npm run build

      - name: Deploy to server via SSH
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: ${{ secrets.SERVER_HOST }}
          username: ${{ secrets.SERVER_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          port: 22
          script: |
            cd /var/www/yourdomain.com
            git pull origin main
            npm ci --production
            pm2 restart my-app
            echo "Deployment complete!"

Setting Up GitHub Secrets

Go to your GitHub repo → SettingsSecrets and variablesActions and add:

SERVER_HOST — Your server's IP address or domain
SERVER_USER — SSH username (e.g., deploy)
SSH_PRIVATE_KEY — Contents of your ~/.ssh/id_rsa private key

GitHub Actions Workflow: Deploy PHP App

.github/workflows/deploy-php.yml
name: Deploy PHP App

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'

      - name: Install Composer dependencies
        run: composer install --no-dev --optimize-autoloader

      - name: Deploy via SSH
        uses: appleboy/ssh-action@v1.0.3
        with:
          host: ${{ secrets.SERVER_HOST }}
          username: ${{ secrets.SERVER_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          script: |
            cd /var/www/yourdomain.com
            git pull origin main
            composer install --no-dev --optimize-autoloader
            php artisan migrate --force   # Laravel
            php artisan config:cache
            php artisan route:cache
            sudo systemctl reload php8.1-fpm
            echo "PHP app deployed!"

Advanced: Performance & Security Hardening

Performance Optimization

CDN (Content Delivery Network)
Use Cloudflare (free) or AWS CloudFront to serve static assets from servers closest to your visitors. Reduces latency by 50–80%.
Server-Side Caching
Use Redis or Memcached to cache database queries and session data. Nginx FastCGI cache for PHP apps. Reduces server load dramatically.
Gzip/Brotli Compression
Enable Gzip or Brotli compression on your web server to reduce file sizes by 60–80% before sending to browsers.
Image Optimization
Convert images to WebP format. Use lazy loading. Compress with tools like TinyPNG or Squoosh. Images are often 60% of page weight.

Enable Nginx Gzip Compression

/etc/nginx/nginx.conf
http {
    # Enable Gzip
    gzip on;
    gzip_vary on;
    gzip_proxied any;
    gzip_comp_level 6;
    gzip_min_length 1000;
    gzip_types
        text/plain
        text/css
        text/javascript
        application/javascript
        application/json
        application/xml
        image/svg+xml;

    # Browser caching for static assets
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff2)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}

Security Hardening

WAF (Web Application Firewall)
Cloudflare WAF (free tier available) blocks SQL injection, XSS, and other OWASP Top 10 attacks before they reach your server.
DDoS Protection
Cloudflare's free plan includes basic DDoS protection. For serious protection, use Cloudflare Pro or AWS Shield.
Automated Backups
Schedule daily backups with cron jobs. Store backups off-server (S3, Google Drive). Test restores regularly.
Fail2Ban
Automatically bans IPs that show malicious signs like too many failed SSH login attempts. Essential for any VPS.

Install & Configure Fail2Ban

Terminal
# Install Fail2Ban
sudo apt install fail2ban -y

# Create local config (don't edit jail.conf directly)
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local

# Key settings to configure:
# [DEFAULT]
# bantime  = 3600      # Ban for 1 hour
# findtime = 600       # Within 10 minutes
# maxretry = 5         # After 5 failed attempts

# [sshd]
# enabled = true
# port    = ssh
# logpath = %(sshd_log)s

# Start and enable
sudo systemctl start fail2ban
sudo systemctl enable fail2ban

# Check banned IPs
sudo fail2ban-client status sshd

Automated Backup Script

backup.sh
#!/bin/bash
# Daily backup script - add to cron: 0 2 * * * /home/deploy/backup.sh

DATE=$(date +%Y-%m-%d)
BACKUP_DIR="/home/deploy/backups"
WEB_DIR="/var/www/yourdomain.com"
DB_NAME="your_database"
DB_USER="db_user"
DB_PASS="db_password"

mkdir -p $BACKUP_DIR

# Backup website files
tar -czf "$BACKUP_DIR/files-$DATE.tar.gz" $WEB_DIR

# Backup database
mysqldump -u $DB_USER -p$DB_PASS $DB_NAME | gzip > "$BACKUP_DIR/db-$DATE.sql.gz"

# Delete backups older than 7 days
find $BACKUP_DIR -name "*.gz" -mtime +7 -delete

echo "Backup completed: $DATE"

# Optional: Upload to S3
# aws s3 cp "$BACKUP_DIR/files-$DATE.tar.gz" s3://your-bucket/backups/
# aws s3 cp "$BACKUP_DIR/db-$DATE.sql.gz" s3://your-bucket/backups/

Common Hosting Mistakes to Avoid

Not enabling HTTPS
HTTP sites are flagged as "Not Secure" by browsers and penalized by Google. Always install SSL — it's free with Let's Encrypt.
Storing credentials in code
Never commit database passwords, API keys, or secrets to Git. Use .env files and add them to .gitignore.
No backups
Servers can fail, get hacked, or have accidental data loss. Always maintain automated daily backups stored in a separate location.
Using root user for everything
Always create a non-root user with sudo privileges for daily operations. Running as root is a major security risk.
Ignoring server updates
Outdated software has known vulnerabilities. Run apt update && apt upgrade regularly and enable automatic security updates.
Wrong file permissions
Setting chmod 777 on files is a critical security mistake. Use 755 for directories and 644 for files.
No monitoring or alerts
Without monitoring, you won't know when your site goes down. Set up UptimeRobot (free) and server monitoring with tools like Netdata or Grafana.
Choosing the cheapest host without research
Extremely cheap hosting often means oversold servers, poor support, and frequent downtime. Balance cost with reliability — look for 99.9%+ uptime guarantees.

Summary — Quick Reference

Step Task Tool / Service Difficulty
1Choose a Domain NameHostinger, GoDaddy, NamecheapEasy
2Choose Hosting PlanShared / VPS / CloudEasy
3Connect Domain (Nameservers)Domain Registrar DNS PanelEasy
4Upload Website FilesFileZilla, cPanel, Git+SSHMedium
5Configure SSL/HTTPSLet's Encrypt, Certbot, cPanelMedium
6Configure DNS RecordsA Record, CNAME, MX, TXTMedium
7Test WebsitePageSpeed, SSL Labs, BrowserStackEasy
8VPS Setup (Advanced)SSH, Nginx, UFW, PM2Advanced
9CI/CD PipelineGitHub Actions, SSH DeployAdvanced
10Performance & SecurityCloudflare, Fail2Ban, BackupsAdvanced
Pro Tip
Start simple: buy shared hosting, connect your domain, upload your files, and enable SSL. Once your site grows, migrate to VPS and implement CI/CD. Don't over-engineer from day one.

Ready to Level Up Your Skills?

Explore 500+ free tutorials across 20+ languages and frameworks.