How to Set Up a Debian VPS (Step-by-Step)

Okay, here’s a comprehensive, step-by-step guide on setting up a Debian VPS, aiming for approximately 5000 words. I’ll cover everything from choosing a provider to securing your server.

How to Set Up a Debian VPS (Step-by-Step)

This guide provides a detailed walkthrough of setting up a Debian Virtual Private Server (VPS). We’ll cover every stage, from selecting a VPS provider and initial connection to securing your server and installing essential software. This guide assumes you have little to no prior experience with Linux server administration, but some familiarity with command-line interfaces will be beneficial.

Table of Contents

  1. Choosing a VPS Provider

    • Factors to Consider
    • Popular VPS Providers
    • Price Comparison (Example)
  2. Signing Up and Creating Your VPS

    • Account Creation
    • Selecting an Operating System (Debian)
    • Choosing a Server Location
    • Choosing a Plan (Resources)
    • Obtaining Your IP Address and Root Password
  3. Connecting to Your VPS

    • SSH Clients (PuTTY, Terminal, etc.)
    • Connecting via SSH (Windows, macOS, Linux)
    • Understanding the Root User
  4. Initial Server Setup

    • Updating the Package List
    • Upgrading Existing Packages
    • Creating a New User Account
    • Granting Sudo Privileges
    • Setting Up SSH Key Authentication (Highly Recommended)
      • Generating an SSH Key Pair (Local Machine)
      • Copying the Public Key to the Server
      • Testing SSH Key Authentication
      • Disabling Password Authentication
    • Configuring the Firewall (UFW)
      • Installing UFW
      • Allowing SSH Connections
      • Allowing Other Necessary Ports (HTTP, HTTPS, etc.)
      • Enabling the Firewall
      • Checking Firewall Status
  5. Basic Server Hardening and Security

    • Changing the Default SSH Port (Optional but Recommended)
    • Installing and Configuring Fail2ban
      • Installation
      • Configuration
    • Regularly Checking Logs
      • Understanding /var/log
      • Key Log Files to Monitor
    • Keeping Your System Updated
      • Automated Updates (Unattended Upgrades)
    • Using a Strong Password Policy
    • Monitoring Server Resources (htop, top)
  6. Installing Essential Software (Examples)

    • Web Server (Apache or Nginx)
      • Installing Apache
      • Installing Nginx
      • Basic Configuration (Virtual Hosts)
    • Database Server (MariaDB or PostgreSQL)
      • Installing MariaDB
      • Installing PostgreSQL
      • Basic Configuration and Security
    • PHP (if needed)
      • Installing PHP and Necessary Modules
      • Configuring PHP with Apache/Nginx
    • Other Useful Tools (e.g., Git, screen, tmux)
  7. Setting Up a Domain Name (Optional)

    • Purchasing a Domain Name
    • Configuring DNS Records (A, CNAME)
    • Pointing Your Domain to Your VPS IP Address
  8. Troubleshooting Common Issues

    • Connection Problems
    • Permission Errors
    • Service Failures
    • Resource Exhaustion
  9. Further Learning and Resources


1. Choosing a VPS Provider

Selecting the right VPS provider is crucial for the performance, reliability, and security of your server. Here are the key factors to consider:

  • Factors to Consider:

    • Price: VPS plans vary significantly in price. Determine your budget and find a plan that meets your needs without overspending. Be wary of extremely cheap plans, as they may come with compromises in performance or support.
    • Resources (CPU, RAM, Storage): Consider the resources your project requires. A simple website or blog will need fewer resources than a resource-intensive application. Start small and scale up as needed. Look for options with:
      • CPU Cores: More cores generally mean better performance for multi-threaded applications.
      • RAM: Sufficient RAM is essential for smooth operation, especially if you’re running a database server.
      • Storage (SSD vs. HDD): SSD (Solid State Drive) storage is significantly faster than HDD (Hard Disk Drive) storage. Opt for SSD whenever possible.
      • Bandwidth: This determines the amount of data that can be transferred to and from your server each month. Choose a plan with enough bandwidth for your expected traffic.
    • Operating System Options: Ensure the provider offers Debian (the focus of this guide). Most providers offer various Debian versions.
    • Server Locations: Choose a server location that is geographically close to your target audience for optimal performance (lower latency).
    • Uptime Guarantee (SLA): Look for a provider with a high uptime guarantee (e.g., 99.9% or higher). This indicates the provider’s commitment to keeping your server online.
    • Customer Support: Good customer support is essential, especially when you’re starting. Look for providers with 24/7 support via multiple channels (live chat, email, phone). Read reviews to gauge the quality of their support.
    • Scalability: Choose a provider that allows you to easily upgrade your plan as your needs grow. You should be able to add more CPU, RAM, and storage without significant downtime.
    • Backup Options: Check if the provider offers automated backups. Regular backups are crucial for data recovery in case of server failure or accidental data loss.
    • Reputation and Reviews: Research the provider’s reputation and read reviews from other users. This can give you insights into their reliability and customer service.
  • Popular VPS Providers:

    • DigitalOcean: Known for its simplicity, developer-friendly features, and competitive pricing. Excellent documentation and a large community.
    • Vultr: Similar to DigitalOcean, offering a wide range of server locations and competitive pricing.
    • Linode: Another popular choice with a strong focus on performance and reliability.
    • AWS Lightsail: Amazon’s simplified VPS offering, integrated with the broader AWS ecosystem. Good for those already familiar with AWS.
    • Google Cloud Compute Engine: Google’s cloud computing platform, offering a wide range of virtual machine options. Can be more complex to set up than some other providers.
    • Hetzner Cloud: A German provider known for very competitive pricing, especially in Europe.
    • OVHcloud: A large European provider with a wide range of services, including VPS.
  • Price Comparison (Example): (This is a simplified example, prices may vary)

    Provider Plan (Example) CPU RAM Storage (SSD) Bandwidth Price (Monthly)
    DigitalOcean Basic Droplet 1 vCPU 1 GB 25 GB 1 TB ~$6
    Vultr Cloud Compute 1 vCPU 1 GB 25 GB 1 TB ~$5
    Linode Nanode 1GB 1 vCPU 1 GB 25 GB 1 TB ~$5
    Hetzner Cloud CX11 1 vCPU 2 GB 20 GB 20 TB ~€4

    Note: These are just starting points. Always check the provider’s website for the most up-to-date pricing and plan details.

2. Signing Up and Creating Your VPS

This section walks through the general process of signing up with a VPS provider and creating your Debian server. The specific steps may vary slightly depending on the provider you choose.

  • Account Creation:

    • Visit the website of your chosen VPS provider.
    • Click on the “Sign Up” or “Get Started” button.
    • Provide your email address, create a password, and complete any required verification steps (e.g., email confirmation).
    • You may need to provide billing information (credit card or other payment method).
  • Selecting an Operating System (Debian):

    • Once logged in, you’ll typically find an option to create a new server (e.g., “Create Droplet” in DigitalOcean, “Deploy New Server” in Vultr).
    • Choose “Debian” as your operating system. Select the desired Debian version (e.g., Debian 11, Debian 12). Newer versions generally offer longer support lifecycles.
  • Choosing a Server Location:

    • Select a server location that is geographically close to your target audience or where you prefer to host your server.
  • Choosing a Plan (Resources):

    • Select a plan that provides the CPU, RAM, storage, and bandwidth you need. Start with a smaller plan and scale up later if necessary.
  • Obtaining Your IP Address and Root Password:

    • After creating your VPS, the provider will display your server’s IP address and the initial root password. Important: Copy the root password and store it securely. You will need this to connect to your server for the first time. Some providers might email you this information. Others might use a one-time password or require you to set a password during the creation process.

3. Connecting to Your VPS

To connect to your VPS, you’ll use a protocol called SSH (Secure Shell). SSH provides a secure, encrypted connection to your server’s command-line interface.

  • SSH Clients:

    • Windows:
      • PuTTY: A popular, free, and open-source SSH client for Windows. Download it from the official website (https://www.putty.org/).
      • Windows Subsystem for Linux (WSL): WSL allows you to run a Linux environment directly on Windows. Once you have WSL installed, you can use the ssh command from the WSL terminal.
      • Git Bash: If you have Git for Windows installed, it includes a Bash shell with the ssh command.
    • macOS:
      • Terminal: macOS comes with a built-in terminal application that includes the ssh command. You can find it in the /Applications/Utilities/ folder.
    • Linux:
      • Terminal: Most Linux distributions come with a terminal application that includes the ssh command.
  • Connecting via SSH (Windows, macOS, Linux):

    • Windows (PuTTY):

      1. Open PuTTY.
      2. In the “Host Name (or IP address)” field, enter your server’s IP address.
      3. Ensure the “Port” is set to 22 (the default SSH port).
      4. Select “SSH” as the connection type.
      5. Click “Open.”
      6. A security alert may appear the first time you connect. Click “Accept” to trust the server’s host key.
      7. You will be prompted for a username. Enter root.
      8. You will be prompted for a password. Enter the root password you obtained from your VPS provider.
    • macOS/Linux (Terminal):

      1. Open the Terminal application.
      2. Type the following command, replacing your_server_ip with your server’s IP address:
        bash
        ssh root@your_server_ip
      3. You may be asked to confirm the authenticity of the host. Type yes and press Enter.
      4. Enter the root password when prompted.
  • Understanding the Root User:

    The root user is the superuser or administrator account on your Debian system. It has unrestricted access to all files and commands. Important: It’s generally not recommended to use the root user for everyday tasks due to the risk of accidental damage. We’ll create a new user account with limited privileges in the next section.

4. Initial Server Setup

Once you’ve successfully connected to your VPS as the root user, you should perform some essential setup tasks to secure and configure your server.

  • Updating the Package List:

    The package list contains information about the software packages available for your system. Update it with the following command:

    bash
    apt update

  • Upgrading Existing Packages:

    After updating the package list, upgrade any installed packages to their latest versions:

    bash
    apt upgrade -y

    The -y flag automatically answers “yes” to any prompts, making the process faster.

  • Creating a New User Account:

    Create a new user account with a descriptive name (e.g., your name or a project name). Replace newuser with your desired username:

    bash
    adduser newuser

    You’ll be prompted to set a password for the new user and provide some optional information. Choose a strong password!

  • Granting Sudo Privileges:

    The sudo command allows you to run commands with root privileges on a per-command basis. This is much safer than logging in directly as root. Add your new user to the sudo group:

    bash
    usermod -aG sudo newuser

  • Setting Up SSH Key Authentication (Highly Recommended):

    SSH key authentication is a more secure alternative to password authentication. It uses a pair of cryptographic keys: a private key (which you keep on your local machine) and a public key (which you place on the server).

    • Generating an SSH Key Pair (Local Machine):

      • macOS/Linux (Terminal):
        bash
        ssh-keygen -t rsa -b 4096

        This command generates an RSA key pair with a 4096-bit key size (recommended for security). You’ll be prompted to choose a location to save the keys (the default is usually ~/.ssh/id_rsa) and to enter an optional passphrase. A passphrase adds an extra layer of security, but it means you’ll need to enter the passphrase every time you use the key.

      • Windows (PuTTYgen):

        1. Open PuTTYgen (it’s usually installed along with PuTTY).
        2. Select “RSA” as the type of key to generate.
        3. Set the “Number of bits in a generated key” to 4096.
        4. Click “Generate.” Move your mouse around to generate randomness.
        5. Enter a passphrase (optional but recommended).
        6. Save the private key (e.g., private.ppk). Keep this file extremely secure!
        7. Copy the text in the “Public key for pasting into OpenSSH authorized_keys file” box. This is the public key you’ll need for the next step.
    • Copying the Public Key to the Server:

      • Easiest Method (ssh-copy-id – macOS/Linux):
        If you generated the key on macOS or Linux, you can use the ssh-copy-id command:
        bash
        ssh-copy-id newuser@your_server_ip

        You’ll be prompted for the newuser password. This command automatically copies the public key to the correct location on the server.

      • Manual Method (All Operating Systems):

        1. Log in to your server as the newuser:
          bash
          ssh newuser@your_server_ip

          Enter the newuser password.
        2. Create the .ssh directory if it doesn’t exist:
          bash
          mkdir -p ~/.ssh
        3. Create the authorized_keys file:
          bash
          nano ~/.ssh/authorized_keys
        4. Paste your public key into the authorized_keys file. Ensure it’s all on one line.
        5. Save the file (Ctrl+O, Enter) and exit the editor (Ctrl+X).
        6. Set the correct permissions on the .ssh directory and authorized_keys file:
          bash
          chmod 700 ~/.ssh
          chmod 600 ~/.ssh/authorized_keys
    • Testing SSH Key Authentication:

      Open a new terminal window or PuTTY session and try connecting to your server using the new user account without entering a password:

      bash
      ssh newuser@your_server_ip

      If you set a passphrase, you’ll be prompted for it. If you didn’t set a passphrase, you should be logged in directly.

    • Disabling Password Authentication:

      Once you’ve confirmed that SSH key authentication is working, it’s highly recommended to disable password authentication for increased security. This prevents attackers from trying to brute-force your password.

      1. Log in to your server as a user with sudo privileges (e.g., newuser).
      2. Edit the SSH configuration file:
        bash
        sudo nano /etc/ssh/sshd_config
      3. Find the following lines and change them as shown:
        PasswordAuthentication no
        ChallengeResponseAuthentication no
      4. Save the file (Ctrl+O, Enter) and exit the editor (Ctrl+X).
      5. Restart the SSH service to apply the changes:
        bash
        sudo systemctl restart ssh

        or
        bash
        sudo service ssh restart

      Important: Make absolutely sure that key-based authentication is working before disabling password authentication. If you disable password authentication and your keys aren’t working, you’ll be locked out of your server!

  • Configuring the Firewall (UFW):

    A firewall is essential for protecting your server from unauthorized access. UFW (Uncomplicated Firewall) is a user-friendly frontend for iptables that makes it easy to configure basic firewall rules.

    • Installing UFW:

      bash
      sudo apt update
      sudo apt install ufw -y

    • Allowing SSH Connections:

      bash
      sudo ufw allow ssh

      This allows incoming connections on port 22 (the default SSH port). If you change the SSH port later, you’ll need to update this rule.

    • Allowing Other Necessary Ports (HTTP, HTTPS, etc.):

      If you plan to run a web server, you’ll need to allow incoming connections on ports 80 (HTTP) and 443 (HTTPS):

      bash
      sudo ufw allow http
      sudo ufw allow https

      Allow any other ports that your applications require. For example, if you are running a MySQL database server and need to allow remote connections to it, you would allow port 3306. Only allow the absolute minimum needed for security.

    • Enabling the Firewall:

      bash
      sudo ufw enable

      You’ll be asked to confirm that you want to enable the firewall. Type y and press Enter.

    • Checking Firewall Status:

      bash
      sudo ufw status

      This will show you the current status of the firewall and the rules that are in place.

5. Basic Server Hardening and Security

Now that you have a basic setup, let’s implement some additional security measures.

  • Changing the Default SSH Port (Optional but Recommended):

    Changing the default SSH port from 22 to a different port can help reduce the number of automated attacks targeting your server. Choose a port number between 1024 and 65535 that isn’t already in use.

    1. Edit the SSH configuration file:
      bash
      sudo nano /etc/ssh/sshd_config
    2. Find the line that says #Port 22 (it might be commented out with a #). Uncomment it and change the port number to your desired port (e.g., Port 2222):
      Port 2222
    3. Save the file and exit the editor.
    4. Update your firewall rule to allow connections on the new port:
      bash
      sudo ufw allow 2222/tcp
    5. Restart the SSH service:
      bash
      sudo systemctl restart ssh
    6. Important: When connecting to your server via SSH, you’ll now need to specify the new port number:
      bash
      ssh -p 2222 newuser@your_server_ip

      (Replace 2222 with your chosen port number.) In PuTTY, you would enter the port number in the “Port” field.
  • Installing and Configuring Fail2ban:

    Fail2ban is a tool that helps protect your server from brute-force attacks by monitoring log files and automatically banning IP addresses that exhibit suspicious behavior (e.g., multiple failed login attempts).

    • Installation:

      bash
      sudo apt update
      sudo apt install fail2ban -y

    • Configuration:

      Fail2ban’s default configuration is usually sufficient for most users, but you can customize it by creating a local configuration file.
      It’s best practice not to modify the original config file (/etc/fail2ban/jail.conf), but rather to create an override in /etc/fail2ban/jail.local.

      bash
      sudo nano /etc/fail2ban/jail.local

      Paste the following basic configuration, and adjust as needed:

      “`
      [DEFAULT]

      Ban hosts for one hour:

      bantime = 1h

      Override /etc/fail2ban/jail.d/00-firewalld.conf:

      banaction = iptables-multiport

      [sshd]
      enabled = true
      “`

      • bantime: Specifies how long an IP address should be banned (e.g., 1h for one hour, 1d for one day).
      • banaction: Specifies the action to take when banning an IP address (usually iptables-multiport).
      • [sshd]: This section configures Fail2ban for the SSH service. enabled = true enables protection for SSH. You might want to add other sections here for services, e.g. [apache-auth]

      Save the file and exit the editor.

      Restart Fail2ban to apply the changes:

      bash
      sudo systemctl restart fail2ban

      You can check the status of Fail2ban with:

      bash
      sudo fail2ban-client status

      And check the status of a specific jail (e.g., sshd) with:
      bash
      sudo fail2ban-client status sshd

  • Regularly Checking Logs:

    Monitoring your server’s log files is crucial for identifying potential security issues, troubleshooting problems, and understanding how your server is being used.

    • Understanding /var/log:

      Most system log files are located in the /var/log directory.

    • Key Log Files to Monitor:

      • /var/log/auth.log: Records authentication-related events, including successful and failed login attempts. This is a crucial log file for security monitoring.
      • /var/log/syslog: A general-purpose log file that contains messages from various system services.
      • /var/log/fail2ban.log: Fail2ban’s log file, showing banned IP addresses and other actions.
      • /var/log/apache2/ (or /var/log/nginx/): If you’re running a web server, these directories contain access and error logs.

      You can view log files using commands like cat, less, more, tail, and grep.

      • tail -f /var/log/auth.log: This command displays the last few lines of the auth.log file and updates in real-time as new entries are added. This is useful for monitoring login attempts.
      • grep "Failed password" /var/log/auth.log: This searches for lines containing “Failed password” in the auth.log.
  • Keeping Your System Updated:

    Regularly updating your system is one of the most important things you can do to keep it secure. Updates often include security patches that fix vulnerabilities.

    • Automated Updates (Unattended Upgrades):

      Debian provides a package called unattended-upgrades that can automatically install security updates.

      1. Install the package:
        bash
        sudo apt update
        sudo apt install unattended-upgrades -y

      2. Configure unattended-upgrades:
        bash
        sudo dpkg-reconfigure --priority=low unattended-upgrades

        You’ll be presented with a series of questions. For basic security updates, you can usually choose to automatically install them. You can also configure it to automatically reboot if necessary (but be cautious with this, as it could interrupt services).

      3. You may also edit the configuration files directly. The main configuration file is /etc/apt/apt.conf.d/50unattended-upgrades. You can specify which updates to install automatically (e.g., security updates only). A common and safe approach is to only automatically install security updates. You can then manually handle other updates.

      4. To enable the service, ensure there’s a file /etc/apt/apt.conf.d/20auto-upgrades with the following contents:

        APT::Periodic::Update-Package-Lists "1";
        APT::Periodic::Unattended-Upgrade "1";

  • Using a Strong Password Policy:

    Enforce strong password policies for all user accounts on your server. Strong passwords should be:

    • At least 12 characters long.
    • Include a mix of uppercase and lowercase letters, numbers, and symbols.
    • Not be based on dictionary words or personal information.
    • Unique for each account.
    • Consider using a password manager to generate and store strong passwords.
  • Monitoring Server Resources (htop, top):

    Use tools like htop and top to monitor your server’s CPU usage, RAM usage, and other resource utilization. This can help you identify performance bottlenecks or potential problems.

    • top: A classic command-line utility that displays a dynamic real-time view of running processes.
    • htop: An interactive process viewer that provides a more user-friendly interface than top. You may need to install it: sudo apt install htop -y

    Run either command in your terminal to see the resource usage. Pay attention to processes that are consuming a large amount of CPU or RAM.

6. Installing Essential Software (Examples)

This section provides examples of how to install some common software packages on your Debian VPS.

  • Web Server (Apache or Nginx):

    • Installing Apache:

      bash
      sudo apt update
      sudo apt install apache2 -y

      After installation, you can access your server’s default web page by entering your server’s IP address in a web browser. You should see the Apache2 Debian Default Page.

    • Installing Nginx:

      bash
      sudo apt update
      sudo apt install nginx -y

      Similarly, after installation, you should see the Nginx welcome page when you access your server’s IP address in a web browser.

    • Basic Configuration (Virtual Hosts):

      Virtual hosts allow you to host multiple websites on a single server.

      • Apache:

        1. Create a directory for your website:
          bash
          sudo mkdir -p /var/www/your_domain.com/public_html

          (Replace your_domain.com with your actual domain name or a descriptive name.)
        2. Set the correct ownership and permissions:
          bash
          sudo chown -R $USER:$USER /var/www/your_domain.com/public_html
          sudo chmod -R 755 /var/www/your_domain.com
        3. Create a virtual host configuration file:
          bash
          sudo nano /etc/apache2/sites-available/your_domain.com.conf
        4. Paste the following configuration, adjusting it as needed:

          apache
          <VirtualHost *:80>
          ServerAdmin webmaster@your_domain.com
          ServerName your_domain.com
          ServerAlias www.your_domain.com
          DocumentRoot /var/www/your_domain.com/public_html
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
          </VirtualHost>

        5. Enable the virtual host:
          bash
          sudo a2ensite your_domain.com.conf

        6. Disable the default virtual host (optional):
          bash
          sudo a2dissite 000-default.conf
        7. Test the configuration for syntax errors:
          bash
          sudo apache2ctl configtest
        8. Reload Apache to apply the changes:
          bash
          sudo systemctl reload apache2
      • Nginx:

        1. Create a directory for your website (same as with Apache).
        2. Create an Nginx configuration file:
          bash
          sudo nano /etc/nginx/sites-available/your_domain.com
        3. Paste the following configuration, adjusting it as needed:

          “`nginx
          server {
          listen 80;
          listen [::]:80;

          root /var/www/your_domain.com/public_html;
          index index.html index.htm index.nginx-debian.html;
          
          server_name your_domain.com www.your_domain.com;
          
          location / {
              try_files $uri $uri/ =404;
          }
          

          }
          “`

        4. Create a symbolic link to enable the site:
          bash
          sudo ln -s /etc/nginx/sites-available/your_domain.com /etc/nginx/sites-enabled/

        5. Remove the default Nginx configuration file (optional):
          “`
          sudo rm /etc/nginx/sites-enabled/default

          6. Test the configuration:bash
          sudo nginx -t
          7. Reload Nginx:bash
          sudo systemctl reload nginx
          “`

  • Database Server (MariaDB or PostgreSQL):

    • Installing MariaDB:

      bash
      sudo apt update
      sudo apt install mariadb-server -y

      After installation, run the security script:

      bash
      sudo mysql_secure_installation

      This script will guide you through setting a root password for MariaDB, removing anonymous users, disallowing remote root login, and removing the test database. It’s highly recommended to follow these steps to secure your database server.

    • Installing PostgreSQL:

      bash
      sudo apt update
      sudo apt install postgresql postgresql-contrib -y

      PostgreSQL creates a default user called postgres. Switch to this user:

      bash
      sudo -i -u postgres

      You can then access the PostgreSQL shell:

      bash
      psql

      Create a new user and database:

      sql
      CREATE USER your_username WITH PASSWORD 'your_password';
      CREATE DATABASE your_database OWNER your_username;

      Exit the PostgreSQL shell (\q) and the postgres user (exit).

    • Basic Configuration and Security: For both MariaDB and PostgreSQL, remember to secure access by setting strong passwords, configuring firewall rules (if remote access is needed), and regularly backing up your databases.

  • PHP (if needed):

    If you plan to run PHP applications (e.g., WordPress, Drupal), you’ll need to install PHP and the appropriate modules for your web server and database.

    • Installing PHP and Necessary Modules:

      For Apache with MariaDB:

      bash
      sudo apt update
      sudo apt install php libapache2-mod-php php-mysql -y

      For Nginx with MariaDB:

      bash
      sudo apt update
      sudo apt install php-fpm php-mysql -y

    • Configuring PHP with Apache/Nginx:

      • Apache: The libapache2-mod-php package usually handles the configuration automatically.
      • Nginx: You’ll need to configure Nginx to use PHP-FPM (FastCGI Process Manager). Edit your Nginx virtual host configuration file (e.g., /etc/nginx/sites-available/your_domain.com) and add a location block for PHP files:

        nginx
        location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; #Adjust php version as necessary
        }

        Make sure the fastcgi_pass directive points to the correct PHP-FPM socket. The version number in the socket path (e.g., php8.1-fpm.sock) may vary depending on the PHP version installed on your system. You can find the correct socket path by checking the PHP-FPM configuration files (usually located in /etc/php/8.1/fpm/pool.d/www.conf – again adjust for version).

        Restart Nginx: sudo systemctl restart nginx

  • Other Useful Tools (e.g., Git, screen, tmux):

    • Git: A version control system used for tracking changes in code.

      bash
      sudo apt install git -y

    • screen: A terminal multiplexer that allows you to run multiple terminal sessions within a single window and detach/reattach them.

      bash
      sudo apt install screen -y

    • tmux: Another terminal multiplexer, similar to screen but with more features.

      bash
      sudo apt install tmux -y

7. Setting Up a Domain Name (Optional)

If you want to access your server using a domain name (e.g., yourdomain.com) instead of an IP address, you’ll need to purchase a domain name and configure DNS records.

  • Purchasing a Domain Name:

    You can purchase a domain name from a domain registrar (

Leave a Comment

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

Scroll to Top