Setting Up Your Server for Web Hosting

Setting Up Your Server for Web Hosting

This overview covers the essential components you need to host websites on your dedicated server.

1. Choose a Web Server

Install either Nginx (recommended for performance) or Apache (recommended for .htaccess compatibility):

apt install nginx -y   # or: apt install apache2 -y

2. Install PHP

apt install php php-fpm php-mysql php-curl php-gd php-mbstring php-xml -y

3. Install a Database

apt install mariadb-server -y
mysql_secure_installation

4. Point Your Domain to the Server

At your domain registrar or DNS provider, create an A record:

  • Name: @ (root domain) and www
  • Value: your server's IP address

DNS changes propagate within 1–24 hours.

5. Create a Virtual Host / Server Block

Create a config file for your domain (example for Nginx):

server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/yourdomain.com;
    index index.php index.html;

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

6. Obtain an SSL Certificate

apt install certbot python3-certbot-nginx -y
certbot --nginx -d yourdomain.com -d www.yourdomain.com

7. Upload Your Site Files

Place your website files in /var/www/yourdomain.com/ using SFTP or SCP. Set correct ownership:

chown -R www-data:www-data /var/www/yourdomain.com
  • 0 Корисниците го најдоа ова како корисно
Дали Ви помогна овој одговор?

Понудени резултати

Welcome to Your Dedicated Server

Congratulations on Your New Dedicated Server! This article will help you get oriented and ready...

How to Connect to Your Server via SSH

Connecting to Your Server via SSH SSH (Secure Shell) is the primary method for accessing and...

First-Time Server Setup Checklist

First-Time Server Setup Checklist Complete these steps after first logging into your server to...

Understanding Linux vs Windows Server: Which OS Should You Choose?

Linux vs Windows Server: Which Should You Choose? Choosing an operating system is one of the...

How to Transfer Files to Your Server with SCP and SFTP

Transferring Files to Your Server Two common protocols for moving files to and from your server:...