Category: Uncategorized

  • CresignSys Learn — Lesson 053

    Linux Storage — From Disk to WordPress Files

    We now go one level deeper.

    You know:

    Internet
     ↓
    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL

    You also learned that running programs use:

    CPU
    RAM

    Now we need to understand the third major resource:

    STORAGE


    1. What Is Storage?

    Storage is where data remains after a process stops or the server reboots.

    Examples:

    WordPress files
    Images
    Plugins
    Themes
    Database files
    Logs
    Backups
    SSL certificates
    Configuration files

    2. RAM vs Storage

    Remember:

    RAM
    =
    temporary working memory
    Storage
    =
    persistent data

    For example:

    WordPress
       ↓
    stored on disk
    
    WordPress process
       ↓
    uses RAM while running

    3. Physical Storage

    Your VPS ultimately uses some form of physical storage behind the virtualization layer.

    It may be backed by:

    SSD
    NVMe
    network-attached block storage
    cloud storage

    You don’t necessarily see the underlying physical device directly.


    4. Device

    Linux represents storage devices using device files.

    For example:

    /dev/sda

    or:

    /dev/vda

    or:

    /dev/nvme0n1

    The exact name depends on the virtual machine and storage configuration.


    5. Check Your Disks

    Run:

    lsblk

    You may see something like:

    NAME        SIZE TYPE
    sda         100G disk
    ├─sda1       99G part
    └─sda2        1G part

    Your output will depend on your VPS.


    6. Disk vs Partition

    A physical/virtual disk can be divided into:

    Partitions

    Conceptually:

    Disk
    │
    ├── Partition 1
    ├── Partition 2
    └── Partition 3

    7. Why Partitions?

    Partitions allow different portions of a disk to be managed separately.

    For example:

    Disk
     ↓
    Partition
     ↓
    Filesystem

    A system might have:

    /
     /boot
     /home

    on separate filesystems or partitions, depending on configuration.

    Modern Linux systems can also use LVM, ZFS, Btrfs, RAID, and other storage architectures.


    8. Filesystem

    A partition isn’t automatically a directory full of files.

    You generally put a:

    Filesystem

    on a storage device/partition.

    Common Linux filesystems include:

    ext4
    xfs
    btrfs

    Ubuntu installations commonly use:

    ext4

    though your particular server may differ.


    9. Filesystem Job

    The filesystem organizes:

    Files
    Directories
    Metadata
    Permissions
    Ownership
    Inodes
    Data blocks

    Conceptually:

    Disk
     ↓
    Partition
     ↓
    Filesystem
     ↓
    Files

    10. Mounting

    Linux makes a filesystem accessible through a:

    Mount Point

    For example:

    /dev/sda1
          ↓
         /

    The filesystem becomes accessible through:

    /

    11. Root Filesystem

    Linux has one main filesystem tree beginning at:

    /

    This is called:

    Root directory

    Everything appears underneath it.


    12. Linux Does Not Use Windows-Style Drive Letters

    Windows commonly uses:

    C:\
    D:\

    Linux instead uses:

    /

    and mounts additional filesystems into directories.


    13. Linux Directory Tree

    A simplified Linux filesystem looks like:

    /
    ├── bin
    ├── boot
    ├── dev
    ├── etc
    ├── home
    ├── lib
    ├── opt
    ├── proc
    ├── root
    ├── run
    ├── srv
    ├── storage
    ├── sys
    ├── tmp
    ├── usr
    └── var

    14. /etc

    Usually contains system and application configuration.

    Examples:

    /etc/nginx/
    /etc/mysql/
    /etc/php/

    This is where much of your hosting configuration lives.


    15. /var

    Contains variable data.

    Examples:

    /var/log/
    /var/lib/
    /var/cache/

    You may find:

    /var/log/nginx/

    and:

    /var/log/mysql/

    depending on configuration.


    16. /usr

    Contains many installed programs and supporting files.

    For example:

    /usr/bin/
    /usr/sbin/
    /usr/lib/

    You may find executable programs such as Nginx-related binaries here depending on the package.


    17. /home

    Often contains normal users’ home directories.

    For example:

    /home/user/

    But web hosting files don’t have to live under /home.


    18. /root

    This is the home directory of the root user:

    /root

    It is not the same thing as:

    /

    This distinction is important.


    19. /tmp

    Temporary files are commonly stored here.

    /tmp

    Do not assume everything in /tmp is permanent.


    20. /run

    Contains runtime state created during boot and while services run.

    Examples include:

    PID files
    Unix sockets
    runtime information

    You previously saw a PHP-FPM socket such as:

    /run/php/php8.3-fpm.sock

    21. /dev

    Contains device interfaces.

    For example:

    /dev/sda
    /dev/null
    /dev/random

    These are not ordinary files in the usual sense.


    22. /proc

    You already encountered:

    /proc

    It exposes kernel/process information through a virtual filesystem.

    It does not represent ordinary persistent disk storage.


    23. /sys

    Similarly:

    /sys

    exposes information and interfaces related to devices and the kernel.


    24. Your Hosting Directory

    You have been using a structure similar to:

    /storage/websites/

    For example:

    /storage/websites/learn.cresignsys.com/public/

    This is simply a directory in the Linux filesystem.

    The important question is:

    What filesystem is mounted underneath /storage?


    25. Check Mounts

    Run:

    df -h

    This shows filesystem usage and mount points.


    26. Example df -h

    You might see:

    Filesystem      Size  Used Avail Use% Mounted on
    /dev/sda1       100G   40G   60G  40% /

    Meaning roughly:

    100 GB total
    40 GB used
    60 GB available

    27. Why df Is Important

    Suppose WordPress reports:

    No space left on device

    You should check:

    df -h

    before assuming the WordPress installation is broken.


    28. But Disk Space Is Not the Only Problem

    A filesystem can have:

    free storage

    but still be unable to create a new file because it has:

    no free inodes

    This is a deeper Linux storage concept.


    29. Inode

    An:

    inode

    stores filesystem metadata about a file.

    Conceptually:

    File
     ↓
    inode
     ↓
    metadata + pointers to data

    Metadata can include things such as:

    owner
    group
    permissions
    timestamps
    file type
    size
    data block references

    30. Filename vs Inode

    A directory entry associates:

    filename
     ↓
    inode

    The inode represents the underlying file metadata.

    This is a very important Linux filesystem concept.


    31. Example

    Suppose you have:

    hello.txt

    The filename is not the entire file identity.

    Conceptually:

    Directory
       │
       └── hello.txt
              ↓
           inode 12345
              ↓
           file data

    32. Why Inodes Matter for Hosting

    Imagine a hosting server containing:

    millions of tiny files

    The server may have plenty of gigabytes available but run out of inodes.

    Then creating new files can fail.


    33. Check Inodes

    Run:

    df -i

    You may see:

    Filesystem     Inodes   IUsed   IFree IUse%
    /dev/sda1      6.5M     2M      4.5M  31%

    Exact values vary.


    34. Two Different Storage Problems

    Disk capacity

    df -h

    Inode capacity

    df -i

    Both matter.


    35. WordPress Creates Many Files

    A WordPress installation can contain:

    core files
    plugins
    themes
    uploads
    cache
    logs
    temporary files

    A hosting platform with hundreds of sites can accumulate a very large number of files.


    36. Disk Usage by Directory

    Use:

    du -sh /storage/*

    This gives a high-level size for each directory.


    37. Find Large Directories

    For example:

    sudo du -h --max-depth=1 /storage | sort -h

    This helps identify which directories consume storage.


    38. Find Large Websites

    If you have:

    /storage/websites/

    you can inspect:

    sudo du -sh /storage/websites/*

    You might discover:

    site1.com       500M
    site2.com       2.1G
    site3.com       12G

    39. Why One Website Can Become Huge

    WordPress storage can grow through:

    uploads
    backups
    cache
    logs
    old plugins
    unused themes
    database dumps

    A site may start at:

    500 MB

    and eventually become:

    20 GB

    depending on content and backup strategy.


    40. Uploads

    A common large directory:

    wp-content/uploads/

    It contains images and other uploaded media.

    For a photography website, this could become very large.


    41. Backups

    A common hosting mistake is storing many full backups on the same VPS.

    For example:

    backup-1.tar.gz
    backup-2.tar.gz
    backup-3.tar.gz
    ...

    Eventually:

    disk full

    A production backup strategy should generally include off-server storage.


    42. Logs

    Logs can also grow.

    Examples:

    /var/log/nginx/
    /var/log/mysql/

    and application logs.

    Linux uses mechanisms such as logrotate and journald to manage many logs, but configurations should still be monitored.


    43. Log Rotation

    Instead of:

    access.log

    growing forever, you can have:

    access.log
    access.log.1
    access.log.2.gz
    ...

    Old logs can be compressed or deleted according to policy.


    44. File Permissions

    Now we reach one of the most important hosting concepts:

    Permissions

    Every file and directory has access permissions.

    Example:

    -rw-r--r--

    45. Three Permission Categories

    Linux permissions traditionally distinguish:

    user
    group
    others

    For example:

    -rwxr-xr--

    means conceptually:

    user
    rwx
    
    group
    r-x
    
    others
    r--

    46. Read

    r

    means:

    Read

    For a regular file:

    Can read its contents.


    47. Write

    w

    means:

    Write

    For a regular file:

    Can modify its contents.


    48. Execute

    x

    means:

    Execute

    For a regular file:

    Can execute it as a program, subject to other requirements.

    For a directory, x has a different but very important meaning: it allows traversal/search through that directory.


    49. Directory Permissions

    This is a common beginner trap.

    For a directory:

    r

    means roughly:

    Can list directory entries.

    w

    means:

    Can create/delete/rename entries, subject to the directory’s other controls.

    x

    means:

    Can traverse/access entries by name.


    50. Example

    A directory:

    drwxr-xr-x

    means:

    d
    =
    directory
    
    rwx
    =
    owner
    
    r-x
    =
    group
    
    r-x
    =
    others

    51. Ownership

    Every file has an owner and group.

    Check with:

    ls -l

    You might see:

    -rw-r--r-- 1 www-data www-data index.php

    Meaning:

    owner = www-data
    group = www-data

    52. Why www-data?

    On Ubuntu/Debian-style systems, web services commonly run under a user such as:

    www-data

    depending on the service configuration.

    This user may need access to website files.


    53. Your WordPress Directory

    For example:

    /storage/websites/learn.cresignsys.com/public/

    could have ownership:

    www-data:www-data

    depending on your hosting architecture.

    But ownership should be chosen deliberately rather than blindly applied everywhere.


    54. Permission Problem Example

    Suppose WordPress needs to write:

    wp-content/uploads/

    but PHP-FPM runs as:

    www-data

    and that directory is not writable by the relevant user/group.

    Then WordPress may fail to upload files.


    55. Another Permission Problem

    Suppose Nginx needs to serve:

    index.php

    but cannot traverse:

    /storage/websites/

    because a parent directory lacks appropriate execute permissions.

    The file itself may be readable, but the path can still be inaccessible.


    56. Path Permissions Matter

    For:

    /storage/websites/site/public/index.php

    the process needs appropriate access through:

    /storage
    /storage/websites
    /storage/websites/site
    /storage/websites/site/public

    not just permission on:

    index.php

    57. chmod

    chmod changes permissions.

    For example:

    chmod 644 file.txt

    means:

    owner = rw-
    group = r--
    others = r--

    58. Numeric Permissions

    Common values:

    4 = read
    2 = write
    1 = execute

    Add them:

    7 = rwx
    6 = rw-
    5 = r-x
    4 = r--

    59. Example 755

    755

    means:

    7 = rwx
    5 = r-x
    5 = r-x

    So:

    owner: rwx
    group: r-x
    others: r-x

    60. Example 644

    644

    means:

    owner: rw-
    group: r--
    others: r--

    This is commonly suitable for many regular web files, depending on your security model.


    61. Don’t Blindly Use 777

    You may see advice such as:

    chmod -R 777 public/

    Avoid this as a general solution.

    It grants broad write access and can create serious security problems.


    62. chown

    chown changes ownership.

    Example:

    sudo chown www-data:www-data file.php

    This sets:

    owner = www-data
    group = www-data

    63. Recursive Ownership

    You can use:

    sudo chown -R www-data:www-data directory/

    But be careful.

    Recursive ownership changes can unintentionally affect:

    configuration
    private files
    SSH-related files
    deployment files

    Always inspect before applying recursively.


    64. ls -la

    Use:

    ls -la

    to see:

    permissions
    owner
    group
    hidden files

    This is one of the most useful Linux commands.


    65. Symbolic Links

    Linux also supports:

    Symbolic links

    or:

    symlinks

    Example:

    current
     ↓
    release-2026-08-13

    The symlink points to another path.


    66. Create Symlink

    ln -s /path/to/target /path/to/link

    Example:

    ln -s /storage/websites/site/public /var/www/site

    Now:

    /var/www/site

    points to:

    /storage/websites/site/public

    67. Why Hosting Systems Use Symlinks

    A hosting platform might organize:

    /storage/websites/site/releases/
    /storage/websites/site/current

    where:

    current

    points to the active release.

    This can make deployments easier.


    68. Symlink vs Copy

    A symlink:

    points to existing data

    A copy:

    duplicates data

    So:

    symlink
    =
    reference

    not:

    duplicate

    69. Hard Link

    Linux also supports:

    Hard links

    A hard link is another directory entry referring to the same inode.

    Conceptually:

    file1
      ↓
     inode 123
      ↑
    file2

    Both names refer to the same underlying file data.


    70. Symlink vs Hard Link

    Symlink

    name
     ↓
    path
     ↓
    target

    Hard link

    name1 ─┐
           ├→ same inode
    name2 ─┘

    This distinction becomes important in advanced filesystem administration.


    71. Mount Point

    Suppose you have:

    /storage

    and a separate filesystem is mounted there.

    Then:

    /storage

    becomes the entry point to that filesystem.


    72. Why This Matters for Your Server

    You have used:

    /storage/websites/

    If /storage is a separate mounted disk:

    root filesystem
    +
    storage filesystem

    then your website data is separated from the root filesystem.


    73. Check Mounts

    Run:

    findmnt

    or:

    df -h

    You may discover:

    /dev/sda1 → /
    /dev/sdb1 → /storage

    74. Separate Storage Advantage

    Suppose:

    / = 50 GB
    /storage = 500 GB

    Then:

    OS
    configs
    packages

    can remain on:

    /

    while:

    websites
    uploads

    live on:

    /storage

    75. But Mount Failure Can Be Serious

    Imagine /storage normally contains:

    /storage/websites/

    But after a reboot, the storage filesystem isn’t mounted.

    Then:

    /storage

    may still exist as an ordinary directory on the root filesystem.

    Your scripts could accidentally write website data there.

    This is a potentially dangerous failure mode.


    76. Why This Is Dangerous

    Suppose:

    /storage

    is normally a 500 GB filesystem.

    After a mount failure:

    /storage

    might refer only to a directory on /.

    A hosting script could continue:

    creating websites

    and fill the root filesystem instead.


    77. Check Before Writing

    A robust hosting platform should verify:

    Is /storage actually mounted?

    For example:

    mountpoint /storage

    If it returns that /storage is not a mountpoint, your automation should investigate before creating sites.


    78. This Is Important for Your CHP

    Your CresignSys Hosting Platform should eventually perform:

    Create website
     ↓
    Verify /storage mounted
     ↓
    Create directory
     ↓
    Create Nginx configuration
     ↓
    Create database

    Don’t assume storage is always mounted.


    79. Filesystem Read-Only

    Another possible failure:

    filesystem
     ↓
    read-only

    Then applications may fail to create or modify files.

    Check:

    mount

    or:

    findmnt

    for mount options.


    80. “No Space Left on Device”

    This error does not always mean:

    df -h = 100%

    It can also happen when:

    inodes = exhausted

    or in other filesystem/resource scenarios.

    Therefore check both:

    df -h

    and:

    df -i

    81. Disk Usage vs Directory Size

    This is another important distinction.

    du

    measures file/directory usage.

    df

    reports filesystem-level space usage.

    They answer different questions.


    82. Example

    Suppose:

    df -h

    says:

    100 GB used

    but:

    du -sh /*

    doesn’t seem to add up.

    Possible reasons include:

    deleted files still held open by processes
    other mounted filesystems
    special filesystem accounting

    83. Deleted but Still Open

    This is an advanced but very useful Linux concept.

    Suppose a process has:

    large.log

    open.

    Someone deletes the filename:

    rm large.log

    The directory entry disappears.

    But the process still has the file open.

    The storage space may not be reclaimed until the process closes it.


    84. Find Deleted Open Files

    You can investigate with:

    sudo lsof +L1

    This can reveal open files whose directory links have been removed.


    85. Why This Matters

    You might see:

    df -h

    showing:

    90 GB used

    while:

    du

    shows only:

    60 GB

    A deleted-but-open log file could be part of the explanation.


    86. WordPress Storage Structure

    A typical WordPress installation:

    public/
    ├── wp-admin/
    ├── wp-content/
    │   ├── plugins/
    │   ├── themes/
    │   └── uploads/
    ├── wp-includes/
    ├── index.php
    ├── wp-config.php
    └── ...

    87. Which Part Usually Grows?

    Often:

    wp-content/uploads/

    grows with media.

    Also:

    wp-content/cache/

    may grow depending on caching software.

    Plugins can also generate:

    logs
    backups
    temporary files

    88. Database Is Also Storage

    WordPress’s database is not stored as normal PHP files.

    MySQL stores its data in its own data directory and filesystem structures.

    Commonly on Ubuntu this is under:

    /var/lib/mysql/

    depending on configuration.


    89. So Your Website Uses Multiple Storage Areas

    Conceptually:

    /storage/websites/site/
            │
            ├── WordPress files
            └── uploads
    
    /var/lib/mysql/
            │
            └── WordPress database
    
    /var/log/
            │
            └── logs
    
    /etc/
            │
            └── configuration

    90. Backup Must Cover More Than Public Files

    A complete WordPress backup usually needs:

    WordPress files
    +
    database

    For a hosting server, you may also need to consider:

    Nginx configuration
    SSL configuration/certificates as appropriate
    DNS configuration
    server configuration

    depending on your recovery plan.


    91. WordPress File Backup

    You might back up:

    /storage/websites/site/public/

    But that alone does not contain the complete WordPress site state if the database is separate.


    92. Database Backup

    For MySQL, logical backups can be created using tools such as:

    mysqldump

    or newer MySQL dump tooling.

    The exact command depends on your database configuration and authentication setup.


    93. Full Hosting Backup

    A more complete conceptual backup:

    Website
    │
    ├── Files
    ├── Database
    ├── Nginx config
    ├── SSL/ACME configuration
    └── Metadata

    Then store backups somewhere separate from the server.


    94. Why Off-Server Backup?

    If your VPS completely fails:

    VPS
     ↓
    disk lost

    and your only backup is:

    same VPS

    then:

    backup lost too

    Therefore production backups should normally include an off-server copy.


    95. Storage Performance

    Storage isn’t only about capacity.

    There is also:

    IOPS
    throughput
    latency

    96. IOPS

    IOPS means:

    Input/Output Operations Per Second

    A storage device might handle many small operations per second.

    This matters for workloads such as:

    MySQL
    WordPress
    logs
    many small files

    97. Throughput

    Throughput measures how much data can be transferred over time.

    For example:

    500 MB/s

    is a throughput figure.


    98. Latency

    Storage latency is how long an individual operation takes.

    For databases, low latency can be very important.


    99. WordPress and Storage Performance

    A busy WordPress server may perform many operations:

    PHP
     ↓
    read files
     ↓
    MySQL
     ↓
    read/write database pages
     ↓
    logs
     ↓
    cache

    So storage performance can affect page response time.


    100. Disk Space Is Not Enough

    Two VPSs might both have:

    100 GB storage

    but perform differently because of:

    IOPS
    latency
    throughput
    storage architecture

    101. Your Complete Storage Model

    Memorize:

    Physical/virtual storage
            ↓
          device
            ↓
        partition
            ↓
        filesystem
            ↓
          mount
            ↓
       directories
            ↓
          files
            ↓
         inodes
            ↓
       data blocks

    And access is controlled by:

    ownership
    +
    permissions

    102. Your /storage Model

    For your server, think:

    /storage
       │
       └── websites
            │
            ├── site1.com
            │    └── public
            │
            ├── site2.com
            │    └── public
            │
            └── learn.cresignsys.com
                 └── public

    Nginx then points each domain to its appropriate document root.


    103. Nginx Connection

    For example:

    server {
        server_name learn.cresignsys.com;
    
        root /storage/websites/learn.cresignsys.com/public;
    }

    Now the chain becomes:

    learn.cresignsys.com
            ↓
    DNS
            ↓
    VPS
            ↓
    Nginx
            ↓
    /storage/websites/learn.cresignsys.com/public

    104. PHP-FPM Connection

    Then:

    Browser
     ↓
    Nginx
     ↓
    /storage/websites/learn.cresignsys.com/public
     ↓
    PHP file
     ↓
    PHP-FPM

    The filesystem permissions must allow the appropriate processes to access what they need.


    105. The Hosting Administrator’s Storage Checklist

    When a website cannot write files:

    1. Is filesystem mounted?
    2. Is disk space available?
    3. Are inodes available?
    4. Is filesystem read-only?
    5. Who owns the directory?
    6. What permissions exist?
    7. Can PHP-FPM access it?
    8. Are parent directories traversable?
    9. Is there a quota?
    10. Is another filesystem involved?

    106. Essential Commands

    See disks

    lsblk

    See filesystem space

    df -h

    See inode usage

    df -i

    See mounts

    findmnt

    Check storage mount

    mountpoint /storage

    Directory size

    du -sh /storage

    Website sizes

    du -sh /storage/websites/*

    File ownership

    ls -la

    Change ownership

    chown

    Change permissions

    chmod

    Find open deleted files

    sudo lsof +L1

    107. The Four Major Server Resources

    You now understand three very deeply:

    CPU
    RAM
    STORAGE

    And earlier:

    NETWORK

    So a server can be viewed as:

                 SERVER
                    │
          ┌─────────┼─────────┐
          ▼         ▼         ▼
         CPU       RAM      STORAGE
          │         │         │
          └─────────┼─────────┘
                    ▼
                 NETWORK

    All four interact.


    108. Example: Website Becomes Slow

    Possible cause:

    CPU high

    or:

    RAM pressure

    or:

    storage I/O slow

    or:

    network congestion

    or:

    MySQL slow

    or:

    PHP-FPM overloaded

    This is why good server administration requires understanding the whole stack.


    109. Complete CresignSys Hosting Stack

    You now have:

                             USER
                               │
                               ▼
                             DOMAIN
                               │
                               ▼
                              DNS
                               │
                               ▼
                           PUBLIC IP
                               │
                               ▼
                             NETWORK
                               │
                               ▼
                             UBUNTU
                               │
                  ┌────────────┼────────────┐
                  ▼            ▼            ▼
                 CPU          RAM        STORAGE
                  │            │            │
                  └────────────┼────────────┘
                               ▼
                           NGINX PROCESS
                               │
                               ▼
                          PHP-FPM PROCESS
                               │
                               ▼
                           WORDPRESS
                               │
                               ▼
                          MYSQL PROCESS
                               │
                               ▼
                            INNODB
                               │
                               ▼
                              DISK

    Lesson 053 — Core Principle

    The most important concept:

    A Linux file is not simply “data on disk.” It exists inside a filesystem, is represented by metadata such as an inode, belongs to an owner/group, has permissions, and ultimately maps to storage blocks.

    For your hosting platform:

    Domain
     ↓
    Nginx
     ↓
    Document Root
     ↓
    Filesystem
     ↓
    WordPress files

    and:

    WordPress
     ↓
    MySQL
     ↓
    Database files
     ↓
    Filesystem
     ↓
    Storage

    Next Lesson — 054

    Linux Users, Groups & Permissions — The Security Foundation of Hosting

    We will go deeper into:

    root
     ↓
    user
     ↓
    group
     ↓
    UID
     ↓
    GID
     ↓
    www-data
     ↓
    file ownership
     ↓
    directory traversal
     ↓
    chmod
     ↓
    chown
     ↓
    umask
     ↓
    setuid
     ↓
    setgid
     ↓
    sticky bit

    Then we will apply it directly to your hosting structure:

    /storage/websites/
            ↓
    www-data
            ↓
    Nginx
            ↓
    PHP-FPM
            ↓
    WordPress

    and determine exactly who should own your website files and which permissions should be used without resorting to insecure 777 permissions.

  • CresignSys Learn — Lesson 052

    Linux Memory — From RAM to WordPress Hosting

    We now go one level deeper.

    Previously:

    Internet
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL
     ↓
    Linux processes

    Now ask:

    Where do those processes actually live while they are running?

    The answer begins with:

    RAM


    1. What Is RAM?

    RAM means:

    Random Access Memory

    It is the computer’s fast working memory.

    When a program is running:

    Program on disk
          ↓
    loaded into RAM
          ↓
    CPU executes it

    2. Disk vs RAM

    Your VPS has storage:

    SSD / NVMe

    and memory:

    RAM

    They are different.

    Disk

    Stores data persistently:

    WordPress files
    PHP files
    MySQL database
    logs
    images

    RAM

    Holds data actively being used:

    running programs
    temporary data
    cached data
    kernel data

    3. RAM Is Temporary

    If the server loses power:

    RAM
     ↓
    contents disappear

    But:

    SSD
     ↓
    data remains

    assuming the storage itself isn’t damaged.


    4. Why Programs Need RAM

    Suppose you have:

    /usr/sbin/nginx

    on disk.

    When Nginx runs:

    nginx executable
     ↓
    RAM
     ↓
    process

    The CPU works with memory rather than directly executing the program from the storage device in the normal model.


    5. CPU + RAM

    Think:

                  CPU
                   │
                   ▼
                  RAM
                   │
                   ▼
                  Disk

    Very roughly:

    CPU
    =
    does calculations
    
    RAM
    =
    working area
    
    Disk
    =
    persistent storage

    6. Why RAM Is Faster Than Disk

    RAM is designed for fast random access.

    Storage devices are persistent but generally slower than RAM for active memory access.

    Therefore operating systems try to keep actively used information in memory.


    7. Linux Memory Is Not Just “Free or Used”

    Run:

    free -h

    You might see something like:

                   total   used   free   shared  buff/cache  available
    Mem:             8Gi    3Gi    1Gi      ...      ...         ...
    Swap:            2Gi    ...    ...

    The exact values depend on your server.


    8. free -h

    This is one of the most important commands for server administration:

    free -h

    The:

    -h

    means human-readable units.


    9. Total Memory

    Example:

    total = 8 GiB

    means the system has roughly 8 GiB of RAM available to the operating system, subject to hardware/platform reservations.


    10. Used Memory

    The meaning of “used” depends on the Linux memory accounting model and version.

    Don’t immediately assume:

    used = bad

    Linux intentionally uses otherwise-unused RAM for useful caching.


    11. Free Memory

    free is memory that is currently unused.

    But:

    Low free memory does not automatically mean the server is out of memory.

    Linux can reclaim cache when applications need memory.


    12. Available Memory

    This is one of the most useful values.

    Conceptually:

    available
    =
    memory Linux estimates it can make available to applications
    without severe memory pressure

    So when checking:

    free -h

    pay close attention to:

    available

    not just:

    free

    13. Buffers and Cache

    Linux uses memory to cache data.

    Conceptually:

    Disk
     ↓
    RAM cache
     ↓
    faster future access

    For example:

    WordPress file
     ↓
    read from disk
     ↓
    cached in RAM

    Later access may be faster.


    14. Why Linux Uses “Unused” RAM

    Suppose:

    8 GB RAM

    and applications only require:

    3 GB

    Linux can use some of the remaining memory for:

    filesystem cache

    instead of leaving it completely idle.


    15. Cache Can Be Reclaimed

    Suppose an application suddenly needs more memory.

    Linux can reclaim suitable filesystem cache.

    Conceptually:

    Cache
     ↓
    reclaim
     ↓
    RAM available to application

    Therefore:

    cache ≠ permanently occupied application memory

    16. Important Hosting Principle

    Do not say:

    My VPS has only 500 MB free, therefore it is full.

    Instead inspect:

    free -h

    and look at:

    available

    plus swap and actual process usage.


    17. Process Memory

    Every process consumes memory.

    For example:

    Nginx
     ↓
    RAM
    PHP-FPM
     ↓
    RAM
    MySQL
     ↓
    RAM

    18. Multiple PHP Workers

    Suppose PHP-FPM has:

    10 workers

    Each worker may use some amount of memory.

    Conceptually:

    PHP worker 1 → 100 MB
    PHP worker 2 → 100 MB
    PHP worker 3 → 100 MB
    ...

    The actual usage varies substantially by WordPress site, plugins, workload, PHP version, and request.


    19. Why Worker Count Matters

    Suppose you configure:

    pm.max_children = 50

    That does not mean the server will always consume 50 × some fixed amount.

    But under sufficient load, many workers can become active simultaneously.

    If each active worker becomes memory-heavy:

    many workers
     ↓
    high RAM consumption

    20. Simplified Capacity Model

    For planning, think:

    Total RAM
    -
    OS
    -
    MySQL
    -
    Nginx
    -
    PHP-FPM
    -
    other services
    -
    safety margin
    =
    RAM available for growth

    This is much more useful than simply counting websites.


    21. Website Count Does Not Determine RAM

    For example:

    10 static websites

    may require very little application memory.

    While:

    3 busy WordPress websites

    with heavy plugins may require substantially more.

    So:

    number of websites
    ≠
    memory requirement

    22. WordPress Is Dynamic

    A WordPress request can involve:

    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    plugins
     ↓
    theme
     ↓
    database

    Each layer can consume resources.


    23. Example Request

    User visits:

    https://example.com/shop

    The request may trigger:

    Nginx
     ↓
    PHP worker
     ↓
    WordPress
     ↓
    WooCommerce
     ↓
    plugins
     ↓
    MySQL queries

    This can require substantially more CPU and RAM than serving a simple static HTML file.


    24. Virtual Memory

    Linux doesn’t simply give every process a raw piece of physical RAM.

    It provides:

    Virtual Memory

    Conceptually:

    Process
     ↓
    Virtual address space
     ↓
    Linux memory management
     ↓
    Physical RAM

    25. Why Virtual Memory?

    It gives processes an abstraction where each process has its own virtual address space.

    This provides:

    isolation
    flexibility
    memory protection
    efficient sharing

    26. Process Isolation

    Imagine:

    PHP process A

    and:

    PHP process B

    They should not normally be able to arbitrarily overwrite each other’s memory.

    The operating system’s memory protection mechanisms help enforce this separation.


    27. Virtual Address

    A process might use an address such as:

    0x7f123456

    That is a virtual address.

    The CPU’s memory-management hardware and Linux determine where the corresponding data resides in physical memory.


    28. Pages

    Memory is managed in units called:

    Pages

    A common page size is:

    4 KiB

    though systems can support other page sizes.

    Conceptually:

    Virtual memory
    │
    ├── Page
    ├── Page
    ├── Page
    └── Page

    29. Page Table

    Linux and the CPU use:

    Page Tables

    to map virtual addresses to physical memory.

    Conceptually:

    Virtual Page
         ↓
    Page Table
         ↓
    Physical Page

    30. Why This Is Powerful

    A process can think it has a large continuous address space even though its physical memory may be:

    spread across different physical pages

    The operating system manages the mapping.


    31. Memory Protection

    Page-level permissions can distinguish memory as:

    readable
    writable
    executable

    This is an important part of modern operating-system security.


    32. Stack

    A process has a:

    Stack

    The stack is commonly used for things such as:

    function calls
    local variables
    return information

    Conceptually:

    Process
    ├── Code
    ├── Heap
    ├── Stack
    └── Other mappings

    33. Heap

    The:

    Heap

    is memory used dynamically by programs.

    For example:

    program running
     ↓
    needs more dynamic memory
     ↓
    heap allocation

    PHP and other software make extensive use of dynamically allocated memory.


    34. Code / Text Segment

    The executable code of a program is mapped into memory.

    Conceptually:

    Process memory
    │
    ├── Code
    ├── Data
    ├── Heap
    └── Stack

    The exact layout is more complex on modern systems.


    35. Shared Libraries

    Programs often use shared libraries.

    For example:

    PHP
     ↓
    shared libraries

    Rather than every process keeping a completely separate copy of identical library code, the operating system can share suitable memory pages.


    36. Shared Memory

    Multiple processes can sometimes share memory intentionally.

    This can improve efficiency for some workloads.

    Conceptually:

    Process A
         ↘
          Shared Memory
         ↗
    Process B

    37. Swap

    Now we reach an important server concept:

    Swap

    Swap is storage space that Linux can use as backing for memory pages when appropriate.

    It can be:

    swap partition

    or:

    swap file

    38. Swap File

    You previously worked with swapfile concepts on your VPS.

    A swap file might be:

    /swapfile

    Linux can use it as swap space.


    39. Is Swap RAM?

    No.

    This distinction is critical.

    RAM
    =
    physical memory
    Swap
    =
    storage used as backing for memory management

    40. Why Is Swap Much Slower?

    RAM is designed for memory access.

    Storage is much slower for random memory-style access.

    So:

    RAM
     ↓
    fast

    while:

    Swap
     ↓
    much slower

    The exact performance depends on the storage device and workload.


    41. Swap Is Not a Replacement for RAM

    Don’t think:

    8 GB RAM
    +
    8 GB swap
    =
    16 GB fast RAM

    It is not.

    A better model is:

    8 GB RAM
    +
    8 GB emergency/backing capacity

    with significant performance penalties if heavily relied upon.


    42. Why Servers Use Swap

    A small amount of swap can be useful.

    It can provide additional breathing room during temporary memory pressure and can help the system avoid immediate failure in some situations.

    But sustained heavy swapping usually indicates insufficient memory or a workload/configuration problem.


    43. Swap Usage

    Check:

    free -h

    You might see:

    Swap:
    total
    used
    free

    You can also run:

    swapon --show

    44. swapon --show

    This shows configured active swap devices/files.

    Example:

    /swapfile

    45. Disk vs Swap

    Don’t confuse:

    /var/www/

    with:

    /swapfile

    Both may reside on the same SSD, but they serve completely different purposes.


    46. Memory Pressure

    Suppose:

    RAM = almost full

    and applications keep requesting memory.

    Linux may:

    reclaim cache
     ↓
    compress memory if configured
     ↓
    use swap when appropriate
     ↓
    eventually encounter allocation failure

    47. OOM

    OOM means:

    Out Of Memory

    If Linux cannot satisfy memory demands, the system may invoke the:

    OOM Killer


    48. OOM Killer

    The Linux kernel can terminate selected processes to recover memory.

    Conceptually:

    RAM exhausted
          ↓
    memory allocation failure
          ↓
    OOM handling
          ↓
    process killed
          ↓
    memory recovered

    49. Why This Is Dangerous for Hosting

    Imagine:

    MySQL
    PHP-FPM
    Nginx

    all running.

    If memory pressure becomes severe, a critical process could be terminated.

    Then:

    WordPress
     ↓
    database unavailable

    or:

    Nginx
     ↓
    stops responding

    50. Check Kernel Logs

    For memory-related events:

    dmesg | grep -i oom

    or:

    journalctl -k | grep -i oom

    Depending on permissions and configuration, you may need:

    sudo dmesg

    51. Memory Monitoring

    Use:

    free -h

    for a quick summary.

    Use:

    top

    for live process-level information.


    52. top Memory Columns

    In top, you’ll see information such as:

    VIRT
    RES
    SHR
    %MEM

    These require some explanation.


    53. VIRT

    VIRT represents the process’s virtual memory footprint/address space.

    It is not the same as physical RAM actually occupied.

    Therefore:

    VIRT = 2 GB

    does not necessarily mean:

    RAM = 2 GB

    54. RES

    RES means resident memory.

    It is a useful approximation of the amount of physical RAM currently resident for the process, although shared memory accounting means it should not be interpreted as a simple billable per-process total.


    55. SHR

    SHR represents memory associated with shared pages/mappings.

    Again, process memory accounting is more complicated than simply adding all RES values.


    56. Why Can’t You Simply Add Everything?

    Suppose:

    PHP worker A
    RES = 100 MB
    
    PHP worker B
    RES = 100 MB

    Some pages may be shared.

    Therefore:

    100 + 100

    doesn’t necessarily mean:

    200 MB of unique physical RAM

    57. ps

    You can inspect memory usage:

    ps aux --sort=-%mem | head

    This lists processes sorted by memory usage.


    58. Find the Biggest Memory Users

    A useful command:

    ps aux --sort=-rss | head

    This sorts approximately by resident memory.


    59. Typical Hosting Memory Consumers

    On a WordPress VPS, significant memory users can include:

    MySQL
    PHP-FPM
    Nginx
    system services
    monitoring software
    control panels
    backup tools

    The exact ranking varies by workload.


    60. MySQL Memory

    MySQL uses memory for:

    buffer pool
    connections
    sort buffers
    temporary structures
    table caches
    other internal structures

    For InnoDB-heavy WordPress installations, the buffer pool is particularly important.


    61. InnoDB Buffer Pool

    We will go deeper later, but understand the basic concept now:

    MySQL
     ↓
    InnoDB
     ↓
    Buffer Pool
     ↓
    RAM

    The buffer pool caches frequently used table and index pages in memory.


    62. Why Buffer Pool Helps

    Without caching:

    query
     ↓
    disk
     ↓
    data

    With a useful cache:

    query
     ↓
    buffer pool
     ↓
    data

    Memory access can be much faster than storage access.


    63. WordPress Memory

    A WordPress request can use memory for:

    PHP runtime
    WordPress core
    theme
    plugins
    query results
    objects
    buffers

    Heavy plugins can increase memory requirements.


    64. PHP Memory Limit

    WordPress/PHP may have limits such as:

    memory_limit = 256M

    This means a PHP process/request may be restricted by PHP’s memory limit.

    It does not mean:

    the server has exactly 256 MB for PHP

    65. PHP Memory Limit vs VPS RAM

    Suppose:

    VPS RAM = 8 GB

    and:

    PHP memory_limit = 256M

    This does not mean you can safely run:

    32 PHP workers

    without considering their actual memory use and other processes.


    66. Worker Capacity

    A simplified planning model:

    PHP memory per busy worker
    ×
    maximum concurrent workers
    =
    potential PHP memory demand

    Then add:

    MySQL
    Nginx
    OS
    other services
    safety margin

    67. Example

    Suppose actual PHP worker RSS under your workload is approximately:

    80 MB

    and you allow:

    20 workers

    Very roughly:

    80 × 20
    =
    1600 MB

    So PHP could potentially consume around:

    1.6 GB

    under conditions where all 20 workers reach that memory footprint.

    This is a planning approximation, not a guaranteed fixed consumption.


    68. Add MySQL

    Suppose:

    PHP = 1.6 GB
    MySQL = 2 GB
    Nginx + OS + other = 1 GB

    Then:

    ≈ 4.6 GB

    before additional headroom and caching behavior are considered.

    An 8 GB server could be reasonable for such a workload, but actual measurements should drive the final configuration.


    69. Why “How Many Websites Can I Host?” Has No Simple Answer

    Because:

    website count

    is not the correct capacity metric.

    Better metrics are:

    requests per second
    concurrent PHP requests
    PHP worker memory
    database workload
    database memory
    disk I/O
    CPU usage
    RAM usage

    70. Static vs WordPress

    Compare:

    Static HTML

    with:

    WordPress + WooCommerce + plugins

    The second usually requires considerably more server-side processing.

    Therefore a server might host:

    hundreds of low-traffic static sites

    while handling far fewer:

    high-traffic dynamic WordPress sites

    depending on architecture and resources.


    71. Memory and Concurrency

    This is one of the deepest hosting concepts.

    Imagine:

    100 visitors

    arrive at once.

    If every request requires a PHP worker:

    100 concurrent PHP requests

    could create substantial memory pressure.

    But caching can change the situation dramatically.


    72. Page Cache

    If a WordPress page can be served from cache:

    Visitor
     ↓
    Nginx/page cache
     ↓
    HTML

    PHP may not run for every request.

    This can reduce:

    CPU
    RAM
    database load

    73. Full-Page Cache

    Without cache:

    Visitor
     ↓
    Nginx
     ↓
    PHP
     ↓
    WordPress
     ↓
    MySQL

    With effective full-page caching:

    Visitor
     ↓
    Cache
     ↓
    HTML

    This is a major reason caching is important in hosting.


    74. Object Cache

    WordPress can also use object caching.

    Conceptually:

    WordPress
     ↓
    Object Cache
     ↓
    cached database-related objects

    Systems such as Redis can be used for this purpose.


    75. Database Cache

    MySQL/InnoDB also has its own caching mechanisms.

    So a real request can benefit from multiple layers:

    Browser cache
     ↓
    CDN cache
     ↓
    Nginx/page cache
     ↓
    Object cache
     ↓
    MySQL/InnoDB buffer pool
     ↓
    Disk

    Each layer can reduce work at the next layer.


    76. Memory Hierarchy

    Now you can see a bigger picture:

    CPU registers
          ↓
    CPU cache
          ↓
    RAM
          ↓
    SSD/NVMe
          ↓
    Remote storage/network

    Generally:

    higher
    speed
    ↑
    
    lower
    capacity

    closer to the CPU.


    77. Why Caching Exists Everywhere

    Caching exists because different storage/memory layers have different speeds.

    Example:

    CPU
     ↓
    L1/L2/L3 cache
     ↓
    RAM
     ↓
    SSD

    A good system tries to keep frequently needed data closer to where it is used.


    78. Memory Pressure and Hosting

    When your server approaches serious memory pressure:

    RAM
     ↓
    cache reclaim
     ↓
    swap
     ↓
    slowdown
     ↓
    OOM risk

    Therefore a professional hosting server should not operate continuously at the absolute edge of available memory.


    79. Practical Monitoring

    Start with:

    free -h

    Then:

    top

    Then:

    ps aux --sort=-%mem | head -20

    Then inspect swap:

    swapon --show

    80. Check Memory Pressure

    On Linux systems that expose it, you can inspect:

    cat /proc/meminfo

    This provides detailed kernel memory accounting.


    81. /proc/meminfo

    You will see values such as:

    MemTotal
    MemFree
    MemAvailable
    Buffers
    Cached
    SwapTotal
    SwapFree

    There are many more.

    Don’t try to memorize them all yet.


    82. The /proc Filesystem

    This introduces another important Linux concept.

    /proc

    is a virtual filesystem exposing information about:

    processes
    kernel
    memory
    CPU
    system configuration

    It is not an ordinary disk directory containing regular stored files.


    83. Process Information

    For a process:

    /proc/PID/

    contains information about that process.

    For example:

    ls /proc/1

    shows information related to PID 1.


    84. Memory Information

    cat /proc/meminfo

    gives a much deeper view of system memory.


    85. CPU Information

    cat /proc/cpuinfo

    shows processor information.

    Again, you don’t need to memorize it now.


    86. Linux Memory Mental Model

    Memorize this:

    Program
     ↓
    Process
     ↓
    Virtual Memory
     ↓
    Pages
     ↓
    Physical RAM

    And when RAM becomes constrained:

    RAM pressure
     ↓
    reclaim cache
     ↓
    swap if needed
     ↓
    OOM risk

    87. WordPress Hosting Mental Model

    For your VPS:

                     VPS RAM
                        │
           ┌────────────┼────────────┐
           ▼            ▼            ▼
         Nginx       PHP-FPM       MySQL
                        │            │
                   PHP workers   Buffer Pool
                        │            │
                        └──────┬─────┘
                               ▼
                           WordPress

    The number of PHP workers and the database workload are major capacity considerations.


    88. Most Important Commands

    Memorize these:

    free -h
    top
    ps aux --sort=-%mem | head
    swapon --show
    cat /proc/meminfo
    nproc

    89. The Complete Architecture So Far

    USER
     │
     ▼
    DOMAIN
     │
     ▼
    DNS
     │
     ▼
    IP
     │
     ▼
    TCP
     │
     ▼
    TLS
     │
     ▼
    HTTP
     │
     ▼
    NGINX PROCESS
     │
     ▼
    PHP-FPM PROCESS
     │
     ▼
    WORDPRESS
     │
     ▼
    MYSQL PROCESS
     │
     ▼
    INNODB BUFFER POOL
     │
     ▼
    RAM
     │
     ▼
    CACHE / DISK

    And underneath everything:

    CPU
     +
    RAM
     +
    STORAGE
     +
    LINUX KERNEL

    Lesson 052 — Core Principle

    The key idea is:

    RAM is the active working space of the server, and every running service competes for it.

    For WordPress hosting, the most important memory consumers are often:

    PHP-FPM workers
    +
    MySQL/InnoDB
    +
    OS
    +
    Nginx
    +
    other services

    And the most important capacity concept is:

    RAM capacity
    ≠
    number of websites

    Instead:

    RAM capacity
    =
    concurrent workload
    +
    process memory
    +
    database memory
    +
    OS/services
    +
    safety margin

    Next Lesson — 053

    Linux Storage — From / to Your WordPress Files

    We will go deeper into:

    Disk
     ↓
    Partition
     ↓
    Filesystem
     ↓
    Mount
     ↓
    Directory
     ↓
    File
     ↓
    Inode
     ↓
    Permissions
     ↓
    Ownership
     ↓
    Hard link
     ↓
    Symbolic link
     ↓
    Disk space
     ↓
    Inode space

    Then we will map exactly how your hosting structure works:

    /storage/websites/
        ├── domain1/
        ├── domain2/
        ├── learn.cresignsys.com/
        └── shop.cresignsys.com/

    and why a website can have plenty of disk space but still fail because of permissions, inodes, mounts, or filesystem problems.

  • CresignSys Learn — Lesson 051

    Linux Processes — From Program to Running Service

    We now move one layer deeper into Ubuntu.

    You have learned:

    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL

    But what is Nginx actually doing inside Linux?

    It is a process.

    The same is true for:

    mysqld
    php-fpm
    sshd
    cron
    certbot

    1. Program vs Process

    These two words are often confused.

    Program

    A program is software stored on disk.

    Example:

    /usr/sbin/nginx

    Process

    A process is a running instance of a program.

    Conceptually:

    Program on disk
          ↓
        execute
          ↓
    Process in RAM

    2. Simple Example

    You have:

    nginx

    installed on the server.

    That means the program exists.

    But it doesn’t necessarily mean Nginx is running.

    You can have:

    Installed ✓
    Running ✗

    3. Running Program

    When Linux starts Nginx:

    nginx program
          ↓
    loaded into memory
          ↓
    process
          ↓
    CPU executes instructions

    Now Nginx is running.


    4. PID

    Every Linux process has a:

    PID

    Process ID.

    Example:

    nginx
    PID 1234

    The PID identifies that running process.


    5. Find Processes

    Use:

    ps aux

    This displays processes currently running.

    You can search:

    ps aux | grep nginx

    6. top

    Another important command:

    top

    It provides a continuously updating view of processes and resource usage.

    You can see:

    PID
    CPU
    RAM
    process

    7. htop

    If installed:

    htop

    provides a more interactive process viewer.


    8. Process Hierarchy

    Linux processes can have parent/child relationships.

    Conceptually:

    Parent
      │
      ├── Child
      ├── Child
      └── Child

    9. PID 1

    On modern Ubuntu systems:

    PID 1

    is normally:

    systemd

    You can verify:

    ps -p 1 -f

    You may see something like:

    /usr/lib/systemd/systemd

    10. Why PID 1 Matters

    systemd is responsible for managing much of the system’s startup and services.

    Conceptually:

    Linux boot
        ↓
    systemd
        ↓
    services

    11. systemd Starts Services

    For example:

    systemd
       │
       ├── nginx
       ├── mysql
       ├── ssh
       └── php-fpm

    This is why you can use:

    systemctl

    to manage services.


    12. systemctl

    For Nginx:

    sudo systemctl status nginx

    For MySQL:

    sudo systemctl status mysql

    For PHP-FPM:

    sudo systemctl status php8.3-fpm

    The exact PHP version depends on your installation.


    13. Service vs Process

    These are not identical concepts.

    A:

    service

    is an operational unit managed by the service manager.

    A:

    process

    is a running execution instance.

    Conceptually:

    systemd service
          ↓
    starts
          ↓
    process

    14. Installed

    Suppose Nginx is installed.

    You might have:

    /usr/sbin/nginx

    But:

    systemctl status nginx

    could show it isn’t running.

    Therefore:

    Installed
    ≠
    Running

    15. Enabled

    Another confusing word is:

    enabled

    If you run:

    sudo systemctl enable nginx

    you are configuring Nginx to start automatically during appropriate system boot.

    This does not necessarily mean:

    Nginx is currently running

    16. Started

    To start it now:

    sudo systemctl start nginx

    So:

    enable
    =
    start automatically at boot
    
    start
    =
    start now

    17. Restart

    sudo systemctl restart nginx

    This stops and starts the service.

    Use it when you actually need a restart.


    18. Reload

    sudo systemctl reload nginx

    A reload asks Nginx to reload configuration while trying to preserve existing service availability.

    For configuration changes, reload is often preferable to a full restart when supported.


    19. Restart vs Reload

    Restart

    stop
     ↓
    start

    Reload

    running Nginx
     ↓
    read new configuration
     ↓
    continue serving

    The exact behavior depends on the service.


    20. Nginx Example

    Suppose you modify:

    /etc/nginx/sites-enabled/example.com

    First:

    sudo nginx -t

    If successful:

    sudo systemctl reload nginx

    This is safer than blindly restarting after every configuration change.


    21. Why nginx -t?

    It tests Nginx configuration syntax and related configuration validity.

    If there is an error:

    nginx -t

    can identify it before you reload.


    22. Very Important Workflow

    Use:

    Edit
     ↓
    nginx -t
     ↓
    If successful
     ↓
    reload
     ↓
    test website

    Not:

    Edit
     ↓
    restart
     ↓
    hope

    23. Process Command

    You can inspect a process:

    ps -p PID -f

    For example:

    ps -p 1234 -f

    24. Find Nginx PID

    pgrep nginx

    or:

    pidof nginx

    25. Process Tree

    A very useful command:

    pstree

    or:

    pstree -p

    This shows process relationships.


    26. Why Process Trees Matter

    You might see:

    systemd
     ├─sshd
     ├─nginx
     │   ├─nginx
     │   └─nginx
     ├─php-fpm
     │   ├─php-fpm
     │   └─php-fpm
     └─mysqld

    This gives you a conceptual picture of the running server.


    27. Nginx Master and Worker Processes

    Nginx commonly uses a master/worker architecture.

    Conceptually:

    nginx master
         │
         ├── worker
         ├── worker
         └── worker

    The master handles management responsibilities.

    Workers handle client connections and requests.


    28. Why Multiple Workers?

    A web server needs to handle many simultaneous connections.

    Instead of one process doing everything:

    one process
     ↓
    many connections

    Nginx can distribute work across worker processes.


    29. PHP-FPM

    PHP-FPM also uses multiple processes.

    Conceptually:

    php-fpm master
          │
          ├── PHP worker
          ├── PHP worker
          ├── PHP worker
          └── PHP worker

    These workers execute PHP requests.


    30. WordPress Request

    Suppose:

    GET /about/

    requires PHP.

    The flow can look like:

    Browser
     ↓
    Nginx worker
     ↓
    FastCGI
     ↓
    PHP-FPM worker
     ↓
    WordPress

    31. PHP-FPM Worker

    A PHP-FPM worker may execute:

    index.php

    Then WordPress loads:

    wp-config.php
    WordPress core
    theme
    plugins

    and eventually talks to MySQL.


    32. MySQL Process

    MySQL normally has a main server process, commonly named:

    mysqld

    You can inspect it:

    ps aux | grep mysqld

    33. SSH Process

    When you connect using SSH:

    ssh user@server

    the server’s SSH service is typically:

    sshd

    There may be multiple processes/threads associated with active SSH sessions.


    34. Cron

    Linux also runs scheduled jobs.

    On modern Ubuntu, scheduled tasks can be managed through several mechanisms, including:

    cron
    systemd timers

    For example, automated maintenance might run periodically.


    35. Certbot / ACME

    Your SSL renewal process might use an ACME client such as Certbot.

    It may run:

    periodically
     ↓
    check certificates
     ↓
    renew when needed

    The exact mechanism depends on how you installed/configured it.


    36. Process Memory

    Every process needs memory.

    Conceptually:

    RAM
    │
    ├── Nginx
    ├── PHP-FPM
    ├── MySQL
    ├── SSH
    ├── systemd
    └── other processes

    37. Why PHP-FPM Can Consume Lots of RAM

    Suppose you have:

    20 PHP workers

    Each worker can consume memory.

    Conceptually:

    20 workers
     ×
    memory per worker
     =
    significant RAM usage

    The actual memory footprint varies by application and workload.


    38. Too Many Workers

    Suppose the server has:

    4 GB RAM

    and you configure too many PHP workers.

    You could reach:

    RAM exhaustion
     ↓
    swap
     ↓
    slow server

    or potentially:

    OOM
     ↓
    process killed

    39. Process CPU

    Processes also consume CPU.

    You might see:

    mysqld
    CPU 80%

    or:

    php-fpm
    CPU 90%

    This helps identify where processing time is going.


    40. CPU Percentage Can Be Misunderstood

    On a multi-core system, CPU percentages reported by tools can sometimes exceed 100% for a process using multiple cores.

    For example:

    4 cores

    can produce an aggregate process usage around:

    400%

    depending on the tool’s measurement convention.


    41. Load Average

    Linux also has:

    Load Average

    Check with:

    uptime

    or:

    top

    You may see:

    load average: 1.20, 0.80, 0.60

    These correspond roughly to:

    1 minute
    5 minutes
    15 minutes

    42. What Does Load Mean?

    Load average is not simply CPU percentage.

    It reflects the number of tasks that are runnable or waiting in certain uninterruptible states.

    So it can reflect:

    CPU pressure
    +
    some I/O-related waiting

    43. Example

    Suppose:

    2 CPU cores

    and load average:

    2.0

    That could indicate approximately full utilization of CPU capacity under certain workloads.

    But interpretation requires looking at CPU and I/O metrics too.


    44. High Load ≠ Automatically Bad

    Suppose:

    8 cores
    load = 4

    That may be perfectly acceptable.

    But:

    2 cores
    load = 15

    is more concerning.

    Always consider CPU count and whether tasks are blocked on I/O.


    45. CPU Count

    Check:

    nproc

    Example:

    4

    means Linux reports four available processing units.


    46. Process States

    Processes can have states such as:

    R
    S
    D
    T
    Z

    The most important beginner concepts:

    R
    =
    running/runnable
    
    S
    =
    sleeping
    
    D
    =
    uninterruptible sleep, often waiting on I/O
    
    Z
    =
    zombie

    47. Zombie Process

    A zombie is a process that has finished execution but whose parent has not yet collected its exit status.

    Conceptually:

    Child
     ↓
    finished
     ↓
    zombie entry

    It is not actively consuming CPU like a running process.


    48. Why Zombies Exist

    The parent process needs to retrieve the child’s termination status.

    This is called:

    Reaping

    Normally, well-behaved process managers handle this.


    49. Don’t Panic About One Zombie

    A single transient zombie isn’t necessarily a serious problem.

    Many persistent zombies may indicate a parent-process bug or management issue.


    50. Killing a Process

    Linux provides:

    kill PID

    This sends a signal to the process.

    For example:

    kill 1234

    The default signal is generally:

    SIGTERM

    51. SIGTERM

    SIGTERM means approximately:

    Please terminate gracefully.

    A process can handle this signal and clean up resources.

    This is preferable to immediately forcing termination.


    52. SIGKILL

    You can use:

    kill -9 PID

    This sends:

    SIGKILL

    The process cannot catch or gracefully handle SIGKILL.

    Use it carefully.


    53. Why kill -9 Is Not the First Choice

    Suppose:

    Nginx

    is stuck.

    You could:

    kill -9

    but graceful termination is generally preferable.

    Use:

    SIGTERM

    first when appropriate.


    54. Service Restart Is Usually Better

    If Nginx is managed by systemd:

    sudo systemctl restart nginx

    is generally preferable to manually killing its processes.

    systemd understands the service lifecycle.


    55. Parent Process

    Suppose:

    PID 100

    starts:

    PID 200

    Then:

    PPID of 200 = 100

    PPID means:

    Parent Process ID


    56. View Parent Process

    ps -o pid,ppid,cmd -p PID

    For example:

    ps -o pid,ppid,cmd -p 200

    57. Why Parent/Child Matters

    If you see:

    php-fpm master
        ↓
    PHP workers

    you can understand why killing one worker may not permanently solve the problem.

    The master may create another worker.


    58. Process Lifecycle

    A simplified process lifecycle:

    Created
       ↓
    Running
       ↓
    Sleeping / Waiting
       ↓
    Running
       ↓
    Exit

    The operating system manages these transitions.


    59. File Descriptors

    Processes interact with files, sockets, pipes, and other resources using:

    File Descriptors

    Examples:

    0 = stdin
    1 = stdout
    2 = stderr

    Network sockets are also represented through file descriptors.


    60. Why This Matters

    Nginx may have many open:

    file descriptors

    for:

    client sockets
    log files
    configuration files
    upstream connections

    61. File Descriptor Limits

    A server can have limits on how many file descriptors a process can use.

    A high-traffic web server needs appropriate limits.

    You can inspect shell limits with:

    ulimit -n

    The actual service limits may be configured differently through systemd or other mechanisms.


    62. Nginx and Many Connections

    Suppose:

    10,000 clients

    are connected.

    Nginx needs enough:

    file descriptors

    and system resources to handle those connections.

    This is one reason scalable hosting requires more than just CPU and RAM.


    63. Process Scheduling

    Linux has a scheduler.

    The scheduler decides which runnable tasks get CPU time.

    Conceptually:

    Process A
    Process B
    Process C
    Process D
           ↓
    CPU scheduler
           ↓
    CPU cores

    64. CPU Time

    Processes share CPU resources.

    For example:

    Nginx
    PHP
    MySQL
    SSH
    system tasks

    all compete for CPU time.

    The Linux scheduler manages this.


    65. Nice Value

    Linux has a concept called:

    Nice

    It influences process scheduling priority.

    A process with a higher nice value generally receives lower scheduling preference relative to processes with lower nice values.

    You can inspect process priorities with tools such as:

    ps

    66. Don’t Tune Nice Randomly

    As a hosting administrator, don’t change process priorities without understanding the workload.

    Most services should run with normal scheduling priority.


    67. systemd Service States

    When you run:

    systemctl status nginx

    you might see:

    active (running)

    This is the state you generally want for a continuously running web server.


    68. Other Important States

    You may see:

    active
    inactive
    failed
    activating
    deactivating

    69. failed

    If you see:

    Active: failed

    something prevented the service from operating successfully.

    Immediately inspect:

    sudo journalctl -u nginx

    or:

    sudo journalctl -u nginx -n 100

    70. Journal

    Ubuntu’s systemd journal stores logs from many services.

    Query:

    journalctl

    For Nginx:

    sudo journalctl -u nginx

    For MySQL:

    sudo journalctl -u mysql

    71. Follow Logs

    To watch new log entries:

    sudo journalctl -u nginx -f

    The:

    -f

    means follow.


    72. Why Logs Matter

    A process saying:

    failed

    doesn’t tell you why.

    The logs often provide the reason.

    For example:

    configuration error
    permission denied
    port already in use
    missing file
    resource exhaustion

    73. Port Already in Use

    Suppose you start a service and see:

    Address already in use

    This usually means another process already owns the port.

    Check:

    sudo ss -ltnp

    For example:

    :80

    might already be occupied by Nginx.


    74. Two Services Cannot Normally Listen on the Same IP/Port

    For example:

    Nginx → 0.0.0.0:80
    Apache → 0.0.0.0:80

    They cannot both normally bind the exact same address/port combination.

    One will fail unless special socket-sharing arrangements are used.


    75. This Explains Apache/Nginx Conflicts

    If Apache is already listening on:

    80

    and you try to start Nginx on:

    80

    Nginx may fail.

    Check:

    sudo ss -ltnp | grep ':80'

    76. Your Server

    You previously worked with:

    Apache
    MySQL
    Nginx
    PHP-FPM

    Understanding processes helps you determine which software is actually serving traffic.

    Don’t assume the installed software is the active software.


    77. Example Diagnostic

    Website isn’t working.

    Run:

    sudo ss -ltnp | grep ':80'

    If you see:

    apache2

    instead of:

    nginx

    then Apache is currently handling port 80.

    That immediately changes your diagnosis.


    78. Another Example

    You expect PHP 8.3:

    systemctl status php8.3-fpm

    but Nginx configuration points to:

    php8.2-fpm.sock

    Then:

    Nginx
     ↓
    wrong PHP-FPM socket
     ↓
    502

    Process/service knowledge helps you detect this.


    79. Unix Socket

    PHP-FPM commonly uses a Unix socket such as:

    /run/php/php8.3-fpm.sock

    This is not a TCP port.

    It is a local IPC endpoint.


    80. IPC

    IPC means:

    Inter-Process Communication

    Processes need ways to communicate.

    Common mechanisms include:

    Unix sockets
    TCP sockets
    pipes
    signals
    shared memory

    81. Nginx → PHP-FPM

    In your hosting setup, it may look like:

    Nginx
     ↓
    Unix socket
     ↓
    PHP-FPM

    rather than:

    Nginx
     ↓
    TCP Internet connection
     ↓
    PHP-FPM

    The first is local communication.


    82. PHP-FPM → MySQL

    PHP may then communicate with MySQL using:

    Unix socket

    or:

    TCP

    depending on the configuration.

    For a local MySQL installation, a Unix socket is common.


    83. Complete Process-Level Flow

    Now combine everything:

    Browser
     ↓
    Internet
     ↓
    Nginx worker process
     ↓
    PHP-FPM worker process
     ↓
    WordPress PHP
     ↓
    MySQL server process
     ↓
    InnoDB
     ↓
    Disk

    This is the actual running-process view of your hosting stack.


    84. Process vs Service vs Port

    These three must not be confused.

    Process

    mysqld PID 1234

    Service

    mysql.service

    Port

    3306

    They are related but different.


    85. Example

    MySQL could be:

    Installed ✓
    Service exists ✓
    Process running ✓
    Port 3306 listening ✗

    This can happen if MySQL is configured to use a Unix socket or another port.

    Therefore:

    Running does not automatically mean “listening on 3306.”


    86. The Same for Nginx

    You could have:

    Nginx process ✓

    but:

    port 443 ✗

    if the configuration only listens on port 80.


    87. The Diagnostic Model

    When a service doesn’t work, ask:

    Is the program installed?
            ↓
    Does the systemd service exist?
            ↓
    Is the service active?
            ↓
    Is the process running?
            ↓
    Is it listening on the expected socket/port?
            ↓
    Is the firewall allowing it?
            ↓
    Does the application respond?

    This is a professional troubleshooting sequence.


    88. Essential Commands

    Processes

    ps aux

    Search process

    ps aux | grep nginx

    Process tree

    pstree -p

    Live process monitoring

    top

    Interactive monitoring

    htop

    Process IDs

    pgrep nginx

    Listening ports

    sudo ss -ltnp

    Service status

    systemctl status nginx

    Service logs

    sudo journalctl -u nginx

    Follow service logs

    sudo journalctl -u nginx -f

    89. One Command Set to Memorize

    For Nginx:

    sudo systemctl status nginx
    sudo nginx -t
    sudo ss -ltnp | grep ':80'
    sudo ss -ltnp | grep ':443'
    sudo journalctl -u nginx -n 100

    This five-command sequence can solve many basic Nginx problems.


    90. Your Hosting Platform Now Has Another Layer

    You previously saw:

    Network
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    MySQL

    Now expand it:

    Linux Kernel
          ↓
    systemd
          ↓
    services
          ↓
    processes
          ↓
    threads
          ↓
    CPU/RAM

    91. Complete Infrastructure Model

                             INTERNET
                                │
                                ▼
                               DNS
                                │
                                ▼
                             IP/TCP
                                │
                                ▼
                               TLS
                                │
                                ▼
                              NGINX
                           processes
                                │
                                ▼
                            PHP-FPM
                           processes
                                │
                                ▼
                           WORDPRESS
                                │
                                ▼
                             MYSQL
                           processes
                                │
                                ▼
                             INNODB
                                │
                                ▼
                              DISK
    
              All running under:
    
                        LINUX KERNEL
                             │
                             ▼
                           SYSTEMD

    92. Most Important Concept of This Lesson

    A server is not just:

    files + configuration

    A running server is:

    software
    +
    processes
    +
    memory
    +
    CPU
    +
    network sockets
    +
    files
    +
    permissions
    +
    services

    93. Next Lesson — 052

    Linux Memory From the Absolute Basics

    We will go underneath the processes and learn:

    RAM
     ↓
    Virtual Memory
     ↓
    Pages
     ↓
    Physical Memory
     ↓
    Heap
     ↓
    Stack
     ↓
    Shared Memory
     ↓
    Cache
     ↓
    Buffer
     ↓
    Swap
     ↓
    OOM Killer

    Then we’ll connect it directly to your hosting server:

    Nginx
    +
    PHP-FPM workers
    +
    MySQL
    +
    Ubuntu
    +
    multiple WordPress websites

    and learn how to calculate whether your VPS has enough RAM for the number of websites you want to host.

  • CresignSys Learn — Lesson 050

    DNS Deep Internals — From Domain Name to Your VPS

    We now go deeper into the system that connects:

    learn.cresignsys.com
            ↓
         IP address
            ↓
       Your VPS

    DNS looks simple:

    domain → IP

    But underneath it is a distributed global database system.


    1. What Is DNS?

    DNS means:

    Domain Name System

    Its basic purpose is:

    Name
     ↓
    Address

    For example:

    example.com
         ↓
    203.0.113.25

    But DNS does much more than IP lookup.

    It also stores information about:

    Websites
    Mail
    Subdomains
    Verification
    Service discovery
    Domain delegation

    2. Why Do We Need DNS?

    Computers can communicate using IP addresses.

    You could theoretically type:

    https://203.0.113.25

    But humans prefer:

    https://example.com

    DNS provides the mapping.


    3. Domain Name Structure

    Take:

    learn.cresignsys.com

    Break it down:

    learn
      .
    cresignsys
      .
    com

    Conceptually:

    learn
    =
    hostname/subdomain
    
    cresignsys
    =
    domain name
    
    com
    =
    top-level domain

    4. Root of DNS

    There is actually an invisible root at the end.

    This:

    example.com

    can technically be represented as:

    example.com.

    The final:

    .

    represents the DNS root.


    5. DNS Hierarchy

    Think of DNS as a tree:

    .
    │
    ├── com
    │    │
    │    └── cresignsys
    │          │
    │          ├── www
    │          ├── learn
    │          └── shop
    │
    └── org

    The root is at the top.


    6. Root DNS

    At the top are the:

    Root Servers

    They don’t normally contain the IP address for every website.

    Instead, they know where to find the authoritative servers for top-level domains.

    For example:

    Root
     ↓
    .com

    7. TLD

    TLD means:

    Top-Level Domain

    Examples:

    .com
    .org
    .net
    .in

    So:

    cresignsys.com

    belongs under:

    .com

    8. Root → TLD

    Suppose a resolver needs:

    example.com

    It can conceptually ask:

    Root:
    Who handles .com?

    The root responds with information about the .com nameservers.


    9. TLD → Domain

    Then the resolver asks the .com DNS infrastructure:

    Who is authoritative for example.com?

    The TLD system responds with the authoritative nameserver information for that domain.


    10. Authoritative DNS

    Now we reach:

    Authoritative Nameserver

    This server is responsible for the actual DNS records for the domain.

    For example:

    example.com
     ↓
    authoritative DNS
     ↓
    A record
     ↓
    203.0.113.25

    11. Three Important DNS Roles

    Remember:

    Root
     ↓
    TLD
     ↓
    Authoritative

    But there is another important participant:

    Recursive Resolver

    12. Recursive Resolver

    Your computer usually does not walk the entire DNS hierarchy itself.

    Instead, it asks a recursive resolver.

    For example:

    Browser
     ↓
    Operating system
     ↓
    DNS resolver

    The resolver performs the work of finding the answer.


    13. Example Resolvers

    Common public DNS resolvers include:

    8.8.8.8
    1.1.1.1

    These are examples, not requirements.

    Your ISP, organization, router, or device can use other resolvers.


    14. Full DNS Journey

    Suppose you enter:

    https://learn.cresignsys.com

    Conceptually:

    Browser
     ↓
    Local DNS cache
     ↓
    Recursive resolver
     ↓
    Root
     ↓
    .com
     ↓
    cresignsys.com authoritative DNS
     ↓
    learn.cresignsys.com record
     ↓
    IP address

    15. But There Is Usually Caching

    The resolver may already know the answer.

    For example:

    Resolver
     ↓
    Cache
     ↓
    IP found

    Then it doesn’t need to ask root/TLD/authoritative servers again.

    This is why DNS is scalable.


    16. TTL

    DNS records have:

    TTL

    Time To Live.

    For example:

    TTL = 3600

    means the record can generally be cached for about:

    3600 seconds
    =
    1 hour

    before the cache should consider it expired and obtain fresh information.


    17. Why TTL Matters

    Suppose:

    learn.cresignsys.com

    currently points to:

    IP A

    You change it to:

    IP B

    Some recursive resolvers may still have:

    IP A

    cached until the TTL expires.


    18. DNS Propagation

    People often say:

    DNS propagation takes time.

    More precisely, DNS changes become visible as cached records expire and resolvers retrieve the updated authoritative information.

    So it isn’t usually a single global “propagation event.”


    19. Example

    Initially:

    TTL = 3600

    Record:

    example.com → IP A

    You change it:

    example.com → IP B

    A resolver that cached IP A shortly before the change might continue returning IP A until its cached TTL expires.

    Another resolver whose cache has already expired may immediately retrieve IP B.

    Therefore different users can temporarily receive different answers.


    20. Lower TTL Before Migration

    Suppose you know:

    Website migration

    is coming.

    You can reduce TTL ahead of time.

    For example:

    3600
     ↓
    300

    Then cached answers expire more quickly.

    But reducing TTL immediately before a change does not magically invalidate already-cached records; the old TTL remains relevant to caches that already stored the record.


    21. DNS Record Types

    The important ones for your hosting platform are:

    A
    AAAA
    CNAME
    MX
    TXT
    NS
    SOA

    Let’s understand each.


    22. A Record

    An:

    A record

    maps a hostname to an IPv4 address.

    Example:

    learn.cresignsys.com
            ↓
    A
            ↓
    203.0.113.25

    23. AAAA Record

    An:

    AAAA record

    maps a hostname to an IPv6 address.

    Example:

    learn.cresignsys.com
            ↓
    AAAA
            ↓
    2001:db8::25

    24. A + AAAA

    A domain can have both:

    A
     ↓
    IPv4
    
    AAAA
     ↓
    IPv6

    Clients may use IPv4 or IPv6 depending on their connectivity and address-selection behavior.


    25. CNAME

    CNAME means:

    Canonical Name

    It creates an alias from one DNS name to another DNS name.

    Example:

    www.example.com
            ↓
    CNAME
            ↓
    example.com

    The target is a hostname, not an IP address.


    26. CNAME vs A

    A:

    www.example.com
     ↓
    203.0.113.25

    CNAME:

    www.example.com
     ↓
    example.com

    The CNAME target is then resolved.


    27. Important CNAME Rule

    A CNAME generally cannot coexist with other ordinary data at the same DNS name.

    For example, you normally don’t configure:

    www.example.com
    CNAME → example.com
    A → 203.0.113.25

    at the same exact name.


    28. MX Record

    MX means:

    Mail Exchange

    It tells mail systems where email for a domain should be delivered.

    Example:

    example.com
     ↓
    MX
     ↓
    mail.example.com

    29. MX Has Priority

    MX records have preference/priority values.

    Example conceptually:

    10 mail1.example.com
    20 mail2.example.com

    Lower preference numbers generally mean higher priority.


    30. TXT Record

    TXT records store text data used by many systems.

    Common uses include:

    Domain verification
    SPF
    DKIM-related data
    DMARC-related policies
    Other service verification

    31. SPF

    SPF helps specify which mail servers are authorized to send mail for a domain.

    It is published using DNS TXT records.

    Conceptually:

    example.com
     ↓
    TXT
     ↓
    SPF policy

    32. DKIM

    DKIM uses cryptographic signatures for email authentication.

    The public key is published through DNS.

    Conceptually:

    Email server
     ↓
    DKIM signature

    and:

    DNS
     ↓
    public DKIM key

    The receiving system can use the public key to verify the signature.


    33. DMARC

    DMARC builds on email authentication mechanisms such as SPF and DKIM.

    It lets domain owners publish policies describing how receiving mail systems should handle messages that fail authentication checks.

    DMARC policies are also published through DNS TXT records.


    34. NS Record

    NS means:

    Name Server

    It identifies the authoritative nameservers for a DNS zone.

    Conceptually:

    cresignsys.com
     ↓
    NS
     ↓
    ns1.example-dns.com
    ns2.example-dns.com

    35. SOA Record

    SOA means:

    Start of Authority

    It contains important information about the DNS zone, including things such as:

    Primary authoritative server
    Zone administrator contact representation
    Serial number
    Refresh
    Retry
    Expire
    Negative caching TTL

    36. What Is a DNS Zone?

    A zone is an administrative portion of the DNS namespace.

    For example:

    cresignsys.com

    could be a DNS zone containing:

    cresignsys.com
    www.cresignsys.com
    learn.cresignsys.com
    shop.cresignsys.com

    The exact delegation structure determines what is included.


    37. Domain vs Zone

    These are related but not identical concepts.

    A domain is part of the DNS namespace.

    A zone is a portion of that namespace managed together by authoritative DNS servers.

    This distinction becomes important when managing DNS professionally.


    38. Subdomain

    For:

    learn.cresignsys.com

    the:

    learn

    label is a subdomain label under:

    cresignsys.com

    You can create:

    learn
    shop
    blog
    api
    mail

    and so on.


    39. Your Hosting Architecture

    You could have:

    cresignsys.com
    │
    ├── www
    ├── learn
    ├── shop
    ├── hosting
    ├── api
    └── blog

    Each can point to:

    same VPS

    or:

    different servers

    40. Multiple Domains, One VPS

    For example:

    domain-a.com
            ↓
    203.0.113.25
    
    domain-b.com
            ↓
    203.0.113.25
    
    domain-c.com
            ↓
    203.0.113.25

    All can reach the same VPS.

    Nginx then determines which website should handle the request based largely on the hostname and server configuration.


    41. DNS Does Not Choose the Website

    This is an important distinction.

    DNS determines:

    domain
     ↓
    IP

    Nginx determines:

    HTTP Host / TLS hostname
     ↓
    website configuration

    So:

    DNS
    =
    Which server?
    
    Nginx
    =
    Which website on that server?

    This is simplified but extremely useful.


    42. Example

    Suppose:

    shop.cresignsys.com

    and:

    learn.cresignsys.com

    both resolve to:

    203.0.113.25

    DNS doesn’t care which WordPress installation should serve the request.

    The request reaches Nginx with the hostname.

    Nginx can then select:

    shop

    or:

    learn

    43. Host Header

    An HTTP request contains a hostname.

    For HTTP/1.1, for example:

    GET /
    Host: learn.cresignsys.com

    Nginx uses this information when matching server blocks.


    44. HTTPS and SNI

    For HTTPS, the hostname is also communicated during TLS through:

    SNI

    So for HTTPS:

    TLS SNI
    +
    HTTP Host

    both help identify the intended website.


    45. DNS Is Before HTTP

    Remember:

    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP

    Therefore Nginx cannot receive an ordinary web request until DNS resolution and network connectivity have gotten the client to the server.


    46. Recursive Resolver Cache

    Suppose:

    Google DNS

    has:

    learn.cresignsys.com
     ↓
    old IP

    cached.

    Your computer asks Google DNS:

    What is learn.cresignsys.com?

    Google DNS may answer from its cache without contacting the authoritative server.


    47. Browser Cache

    Your browser can also cache DNS information.

    So there can be multiple caching layers:

    Browser
     ↓
    Operating system
     ↓
    Local router/ISP resolver
     ↓
    Recursive DNS cache

    Exact behavior varies by system and application.


    48. Why nslookup Can Be Misleading

    If you run:

    nslookup example.com

    you are asking the resolver configured for that system.

    If that resolver has cached data, you may not be seeing the authoritative server directly.


    49. Specify a Resolver

    You previously used:

    nslookup example.com 8.8.8.8

    This explicitly asks Google’s public resolver.

    You can also query another resolver.

    For example:

    nslookup example.com 1.1.1.1

    50. dig

    dig provides more detailed DNS information.

    Basic:

    dig example.com

    Short answer:

    dig +short example.com

    Specific record:

    dig example.com A

    51. Query AAAA

    dig example.com AAAA

    This checks IPv6 records.


    52. Query MX

    dig example.com MX

    Useful when diagnosing email delivery.


    53. Query TXT

    dig example.com TXT

    Useful for verification and email authentication records.


    54. Query NS

    dig example.com NS

    This shows nameserver information.


    55. Query SOA

    dig example.com SOA

    This provides zone authority information.


    56. dig +trace

    One of the most educational DNS commands is:

    dig +trace example.com

    It walks through the DNS hierarchy.

    Conceptually:

    Root
     ↓
    TLD
     ↓
    Authoritative
     ↓
    Answer

    This is extremely useful for learning DNS.


    57. What +trace Shows

    It can demonstrate:

    .
     ↓
    com.
     ↓
    example.com.
     ↓
    authoritative server
     ↓
    A record

    This makes the DNS hierarchy visible.


    58. Authoritative vs Recursive

    This distinction is critical.

    Recursive resolver

    Finds answers on behalf of clients and caches them.

    Authoritative server

    Provides authoritative answers for zones it serves.


    59. Example

    Your computer:

    Laptop
     ↓
    8.8.8.8

    Google DNS is acting as a recursive resolver.

    Then:

    8.8.8.8
     ↓
    authoritative DNS

    The authoritative server provides the domain’s authoritative record.


    60. Who Controls DNS?

    This depends on where you delegate your domain.

    A domain registrar manages registration.

    DNS hosting may be provided by:

    Registrar

    or:

    Dedicated DNS provider

    or:

    Cloud provider

    These are related but separate functions.


    61. Registrar

    A registrar is where a domain is registered.

    For example:

    cresignsys.com

    is registered through a domain registrar.

    The registrar manages registration-related information and allows you to configure nameserver delegation.


    62. Nameserver Delegation

    The registrar tells the DNS hierarchy:

    cresignsys.com
     ↓
    these nameservers are authoritative

    For example:

    ns1.provider.com
    ns2.provider.com

    63. Nameserver Flow

    Conceptually:

    Registrar
     ↓
    delegates domain
     ↓
    authoritative nameservers
     ↓
    DNS records

    64. Why Nameservers Matter

    Suppose you edit an A record at:

    DNS Provider A

    but the domain is actually delegated to:

    DNS Provider B

    Your change won’t affect the authoritative DNS for the domain.

    This is a common configuration mistake.


    65. DNS Diagnostic Question

    When a DNS change doesn’t work, first ask:

    Which nameservers are authoritative for this domain?

    Run:

    dig example.com NS

    Then verify you are editing DNS at the correct provider.


    66. A Record Example for Your Hosting

    Suppose your VPS public IP is:

    203.0.113.25

    You could configure:

    learn.cresignsys.com
    A
    203.0.113.25

    Then:

    learn.cresignsys.com
     ↓
    203.0.113.25

    67. Wildcard DNS

    You can also create:

    *.cresignsys.com

    as a wildcard record.

    For example:

    *.cresignsys.com
    A
    203.0.113.25

    Then many otherwise-unconfigured subdomains can resolve to that IP.

    But wildcard DNS does not automatically create the website configuration in Nginx.


    68. Wildcard DNS ≠ Wildcard SSL

    These are separate:

    Wildcard DNS
    =
    DNS resolution
    Wildcard certificate
    =
    TLS certificate coverage

    You can have one without the other.


    69. Wildcard DNS + Nginx

    Suppose:

    *.cresignsys.com
     ↓
    203.0.113.25

    Then:

    anything.cresignsys.com

    may resolve to your VPS.

    But Nginx still needs to know what to do with:

    anything.cresignsys.com

    70. Wildcard Hosting

    A hosting platform could potentially implement:

    *.cresignsys.com
            ↓
    VPS
            ↓
    Nginx
            ↓
    dynamic website routing

    But production hosting usually uses explicit domain/site configurations or controlled wildcard routing.


    71. DNS and SSL Are Separate

    A common mistake is thinking:

    DNS correct
    =
    SSL correct

    No.

    You need:

    DNS
     ↓
    correct IP
    
    SSL
     ↓
    certificate for correct hostname

    Both must be correct.


    72. DNS and Nginx Are Separate

    Similarly:

    DNS
     ↓
    correct IP

    doesn’t mean:

    Nginx
     ↓
    correct website

    Nginx needs appropriate configuration.


    73. Example Failure

    DNS:

    learn.cresignsys.com
     ↓
    correct VPS

    Nginx:

    server_name learn.cresignsys.com

    missing.

    Result:

    request reaches server
     ↓
    wrong/default server block

    DNS is correct, but the website can still be wrong.


    74. Example Another Failure

    DNS:

    learn.cresignsys.com
     ↓
    old VPS

    Nginx on the new VPS:

    correct

    But users still reach the old VPS.

    The Nginx configuration isn’t the problem.

    DNS is.


    75. DNS Troubleshooting Method

    When a domain doesn’t work:

    1. Check authoritative nameservers
    2. Check A record
    3. Check AAAA record
    4. Check CNAME if used
    5. Check TTL
    6. Check resolver results
    7. Check actual VPS IP
    8. Check TCP 80/443
    9. Check Nginx

    76. First Command

    dig +short example.com

    Ask:

    Does this return the IP I expect?


    77. Second Command

    dig example.com NS

    Ask:

    Are these the nameservers I intended?


    78. Third Command

    dig example.com A

    Ask:

    What IPv4 address is authoritative/returned?


    79. Fourth Command

    dig example.com AAAA

    Ask:

    Is there an IPv6 address?

    If you haven’t configured IPv6 correctly, an incorrect AAAA record can cause connection problems for IPv6-capable clients.


    80. Fifth Command

    dig +trace example.com

    This helps determine where the DNS delegation/lookup path is going wrong.


    81. DNS Failure Categories

    NXDOMAIN

    Means the queried domain name does not exist according to the responding DNS system.

    SERVFAIL

    Means the resolver could not successfully obtain/validate an answer.

    NOERROR with no answer

    The name may exist, but the requested record type may not exist.

    These distinctions are useful when diagnosing DNS.


    82. NXDOMAIN

    Example:

    learn.example.com

    doesn’t exist.

    The resolver can return:

    NXDOMAIN

    Meaning approximately:

    This name does not exist.


    83. SERVFAIL

    Can occur due to problems such as:

    DNSSEC validation failure
    authoritative server failure
    delegation problems
    network/server issues

    The exact cause requires further investigation.


    84. DNSSEC

    DNS can also use:

    DNSSEC

    DNSSEC provides cryptographic validation of DNS data.

    Conceptually:

    DNS
    +
    digital signatures
    =
    DNSSEC

    It helps protect against certain forms of DNS data tampering.


    85. DNSSEC Is Different From TLS

    TLS:

    protects application communication

    DNSSEC:

    authenticates DNS data

    They solve different problems.


    86. TTL and Caching Again

    Suppose:

    A record:
    old IP
    TTL:
    3600

    You change:

    new IP

    A resolver that already cached the old value can continue using it until its cached TTL expires.

    So:

    change DNS
    ≠
    every device immediately changes

    87. Why Different Computers Show Different IPs

    Suppose:

    Computer A
     ↓
    Resolver A
     ↓
    old IP

    while:

    Computer B
     ↓
    Resolver B
     ↓
    new IP

    Both can temporarily happen during a DNS change.


    88. Local Cache

    Your own computer can cache DNS results.

    Windows can display/clear its DNS cache using:

    ipconfig /displaydns

    and:

    ipconfig /flushdns

    Use flushing for troubleshooting; it does not change authoritative DNS.


    89. DNS Is Distributed

    The Internet doesn’t have:

    one giant DNS server

    Instead:

    Root
     ↓
    TLD
     ↓
    Authoritative servers
     ↓
    Recursive resolvers
     ↓
    Caches

    This distributed architecture allows DNS to scale globally.


    90. Your Hosting Platform

    For every website created on your hosting platform, you ultimately need:

    Domain
     ↓
    DNS
     ↓
    VPS IP
     ↓
    Nginx server_name
     ↓
    Website directory
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    Database

    DNS is the first major external connection to the hosting system.


    91. Automated Hosting Workflow

    A future CresignSys hosting system could do:

    Create Website
          ↓
    Domain entered
          ↓
    DNS record created
          ↓
    A record → VPS
          ↓
    Nginx configuration
          ↓
    Website directory
          ↓
    Database
          ↓
    WordPress
          ↓
    SSL
          ↓
    HTTPS

    This is essentially the foundation of a simplified hosting control panel.


    92. The Complete Internet-to-Database Journey

    You can now see the entire journey:

    USER
     │
     ▼
    DOMAIN
     │
     ▼
    DNS
     │
     ▼
    IP ADDRESS
     │
     ▼
    ROUTING
     │
     ▼
    TCP
     │
     ▼
    TLS
     │
     ▼
    HTTP
     │
     ▼
    NGINX
     │
     ▼
    PHP-FPM
     │
     ▼
    WORDPRESS
     │
     ▼
    MYSQL
     │
     ▼
    INNODB
     │
     ▼
    BUFFER POOL
     │
     ▼
    DISK

    That is the foundation of your web-hosting infrastructure.


    93. The Most Important DNS Commands

    Start practicing these:

    dig +short example.com
    dig example.com A
    dig example.com AAAA
    dig example.com NS
    dig example.com MX
    dig example.com TXT
    dig example.com SOA
    dig +trace example.com

    94. Windows Commands

    Since you also manage your server from Windows:

    nslookup example.com

    Specific resolver:

    nslookup example.com 8.8.8.8

    IPv4/IPv6 and other details can be queried interactively with nslookup.


    95. One Important Difference

    Remember:

    nslookup
    =
    simple DNS diagnostic

    while:

    dig
    =
    more detailed DNS analysis

    For serious server administration, learn dig.


    96. Lesson 050 Core Model

    Memorize:

    Domain
     ↓
    Recursive Resolver
     ↓
    Root
     ↓
    TLD
     ↓
    Authoritative DNS
     ↓
    DNS Record
     ↓
    IP

    But if cached:

    Domain
     ↓
    Recursive Resolver
     ↓
    Cache
     ↓
    IP

    97. DNS Record Cheat Sheet

    RecordPurpose
    AIPv4 address
    AAAAIPv6 address
    CNAMEAlias to another hostname
    MXMail server
    TXTText/verification/authentication data
    NSAuthoritative nameserver
    SOAZone authority information

    98. Three Things to Never Confuse

    DNS

    domain → IP

    Nginx

    hostname → website configuration

    TLS

    hostname → certificate/security

    Together:

    DNS
     ↓
    server
     ↓
    Nginx
     ↓
    TLS
     ↓
    website

    Lesson 050 Complete

    Your basic web-hosting architecture is now:

                         INTERNET
                             │
                             ▼
                          DOMAIN
                             │
                             ▼
                            DNS
                             │
                             ▼
                        PUBLIC IP
                             │
                             ▼
                        OCI NETWORK
                             │
                             ▼
                           VNIC
                             │
                             ▼
                          UBUNTU
                             │
                             ▼
                          TCP 443
                             │
                             ▼
                            TLS
                             │
                             ▼
                           NGINX
                             │
                             ▼
                         PHP-FPM
                             │
                             ▼
                         WORDPRESS
                             │
                             ▼
                           MYSQL
                             │
                             ▼
                          INNODB
                             │
                             ▼
                            DISK

    Next Lesson — 051

    Linux Process Management — What Actually Runs on Your VPS?

    We will go underneath the services and understand:

    Program
     ↓
    Process
     ↓
    PID
     ↓
    Parent process
     ↓
    Child process
     ↓
    Thread
     ↓
    CPU
     ↓
    RAM
     ↓
    systemd
     ↓
    service

    Then we will connect it directly to:

    nginx
    php-fpm
    mysqld
    sshd
    cron
    certbot

    and learn why a service can be installed, enabled, running, listening, or crashed—and why those are all different states.

  • CresignSys Learn — Lesson 049

    TLS / HTTPS From the Absolute Basics

    We now understand:

    Browser
     ↓
    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    ???
     ↓
    HTTP
     ↓
    Nginx

    The missing layer is:

    TLS

    TLS is what makes ordinary HTTP into secure HTTPS.


    1. HTTP vs HTTPS

    HTTP:

    Browser
       ↓
    HTTP
       ↓
    Server

    HTTPS:

    Browser
       ↓
    TLS
       ↓
    HTTP
       ↓
    Server

    More precisely:

    HTTP data
       ↓
    TLS protection
       ↓
    TCP
       ↓
    IP

    2. What Does HTTPS Mean?

    HTTPS means:

    HTTP Secure

    It is HTTP transmitted through a secure TLS connection.

    So:

    HTTPS
    =
    HTTP
    +
    TLS

    3. Why Do We Need TLS?

    Imagine sending:

    Username: admin
    Password: secret

    over an unencrypted connection.

    Someone capable of observing the traffic could potentially read the data.

    TLS protects the communication against many forms of network interception.


    4. TLS Provides Three Major Properties

    A useful simplified model is:

    TLS
    │
    ├── Confidentiality
    ├── Integrity
    └── Authentication

    5. Confidentiality

    Confidentiality means:

    Unauthorized observers should not be able to read the protected data.

    Conceptually:

    Browser
       ↓
    encrypted data
       ↓
    Internet
       ↓
    Server

    An observer sees encrypted traffic rather than the original HTTP contents.


    6. Integrity

    Integrity means:

    The data should not be silently modified without detection.

    For example:

    Browser
     ↓
    "Pay ₹100"
     ↓
    Internet
     ↓
    Server

    TLS provides mechanisms that allow the receiver to detect tampering with protected records.


    7. Authentication

    Authentication answers:

    Who am I actually communicating with?

    When you visit:

    https://example.com

    the browser needs confidence that the server is authorized for:

    example.com

    This is where certificates enter.


    8. Certificate

    A TLS certificate is a digitally signed document containing information about an identity and a public key.

    Conceptually:

    Certificate
    │
    ├── Domain identity
    ├── Public key
    ├── Validity period
    ├── Issuer
    └── Digital signature

    9. Example

    A certificate might cover:

    example.com

    and possibly:

    www.example.com

    depending on the certificate’s Subject Alternative Names.


    10. Certificate Is Not the Private Key

    This distinction is extremely important.

    You have:

    Public key
    +
    Private key

    The certificate contains the public key and identity information.

    The private key is kept secret on the server.


    11. Public Key

    A public key can be shared.

    Conceptually:

    Public key
    =
    safe to distribute

    The browser can receive it as part of the certificate.


    12. Private Key

    The private key must remain secret.

    Conceptually:

    Private key
    =
    server secret

    If someone obtains the private key, the security of that certificate’s use can be compromised.


    13. Public-Key Cryptography

    TLS uses asymmetric cryptographic concepts.

    You have:

    Public key
            +
    Private key

    They are mathematically related.

    But the private key cannot feasibly be derived from the public key using ordinary practical computation with current cryptographic assumptions.


    14. Simple Analogy

    Think of:

    Public key
    =
    open padlock
    
    Private key
    =
    key that controls the padlock

    Anyone can have the padlock.

    Only the authorized party should have the private key.

    This is only an analogy; TLS cryptography is more sophisticated.


    15. Certificate Authority

    Who says:

    This public key belongs to example.com?

    A:

    Certificate Authority

    or:

    CA

    does this through digital signatures and certificate issuance.


    16. Examples of Certificate Authorities

    There are many certificate authorities.

    One important one for your hosting setup is:

    Let’s Encrypt

    Let’s Encrypt provides automated, publicly trusted TLS certificates.


    17. Trust Chain

    Your browser doesn’t blindly trust every certificate.

    Instead, it has a set of trusted root certificates.

    Conceptually:

    Browser
       ↓
    Trusted Root CA
       ↓
    Intermediate CA
       ↓
    Your Website Certificate

    This is called a:

    Certificate Chain


    18. Root CA

    A root certificate is trusted by the operating system/browser trust store.

    Conceptually:

    Root CA
     ↓
    trusted

    19. Intermediate CA

    A root CA often signs an intermediate CA.

    Then the intermediate CA issues website certificates.

    Conceptually:

    Root
     ↓
    Intermediate
     ↓
    example.com

    This allows a hierarchy of trust.


    20. Why Not Have the Root Sign Every Website?

    Using intermediates provides separation and operational security.

    The root can remain more protected while intermediates handle certificate issuance.


    21. Certificate Chain

    When your server sends the certificate chain:

    Server
     ↓
    website certificate
     ↓
    intermediate certificate

    the browser can build a path toward a trusted root.


    22. Let’s Encrypt

    For your hosting platform, the simplified process is:

    Domain
     ↓
    prove control
     ↓
    Let's Encrypt
     ↓
    certificate issued
     ↓
    Nginx configured
     ↓
    HTTPS

    23. Domain Validation

    Before issuing a certificate, the CA needs to verify that the requester controls the domain.

    One common method is:

    HTTP-01 Challenge

    The CA asks the server to make a specific resource available.

    Conceptually:

    Let's Encrypt
     ↓
    HTTP request
     ↓
    http://example.com/.well-known/...
     ↓
    your server

    If the expected challenge is returned, domain control is demonstrated.


    24. DNS-01 Challenge

    Another method is:

    DNS-01

    The requester proves control by creating a special DNS TXT record.

    Conceptually:

    Let's Encrypt
     ↓
    DNS query
     ↓
    TXT record
     ↓
    proof of domain control

    This is especially useful for some wildcard certificate scenarios.


    25. HTTP-01 vs DNS-01

    HTTP-01

    Domain
     ↓
    HTTP
     ↓
    challenge file

    DNS-01

    Domain
     ↓
    DNS TXT
     ↓
    challenge

    26. Wildcard Certificates

    Suppose you want:

    *.cresignsys.com

    This can cover subdomains such as:

    learn.cresignsys.com
    shop.cresignsys.com
    hosting.cresignsys.com

    Wildcard certificates generally require DNS-based validation such as DNS-01.


    27. One Certificate Per Domain

    You can have:

    example.com
     ↓
    certificate A

    and:

    shop.example.com
     ↓
    certificate B

    Or one certificate can cover multiple names through SANs.


    28. SAN

    SAN means:

    Subject Alternative Name

    A certificate can contain multiple DNS names.

    For example:

    example.com
    www.example.com
    shop.example.com

    all could potentially be included in one certificate.


    29. Why Your Hosting Platform Needs SSL Automation

    Suppose you have:

    100 websites

    Manually installing certificates would be tedious.

    A hosting platform can automate:

    Domain created
     ↓
    DNS verified
     ↓
    Certificate requested
     ↓
    Challenge completed
     ↓
    Certificate installed
     ↓
    Nginx configured
     ↓
    HTTPS tested
     ↓
    Renewal scheduled

    This is exactly the type of workflow a hosting control panel manages.


    30. TLS Handshake

    Now we reach the deeper part.

    Before encrypted application data is exchanged, the client and server perform a:

    TLS Handshake

    The handshake establishes the parameters needed for the secure connection.


    31. Simplified TLS Flow

    Conceptually:

    Browser
       │
       │ ClientHello
       ▼
    Server
       │
       │ ServerHello
       │ Certificate
       ▼
    Browser
       │
       │ key establishment
       ▼
    Secure keys established
       │
       ▼
    Encrypted HTTP

    This is a simplified conceptual picture.

    Modern TLS 1.3 has a more specific handshake structure.


    32. ClientHello

    The browser begins with information about what it supports.

    Conceptually:

    ClientHello
    │
    ├── TLS versions
    ├── Cipher suites
    ├── Random value
    ├── Extensions
    └── SNI

    33. TLS Version

    Modern servers should generally support modern TLS versions.

    The major modern version is:

    TLS 1.3

    TLS 1.2 is also widely deployed.

    Old versions such as TLS 1.0 and TLS 1.1 should generally not be enabled on modern public websites.


    34. Cipher Suite

    A cipher suite describes cryptographic algorithms used by TLS.

    You may encounter names such as:

    TLS_AES_128_GCM_SHA256

    or:

    TLS_AES_256_GCM_SHA384

    These names look complicated because they describe multiple cryptographic components.


    35. Don’t Memorize Cipher Names Yet

    At this stage, understand:

    Cipher suite
    =
    set of cryptographic algorithms used by TLS

    The important concept is negotiation between client and server.


    36. ServerHello

    The server selects compatible parameters.

    Conceptually:

    Client
     ↓
    supported options
     ↓
    Server
     ↓
    chosen options

    37. Certificate

    The server sends its certificate chain.

    For example:

    Server
     ↓
    example.com certificate
     ↓
    intermediate certificate

    The browser validates the certificate.


    38. Certificate Validation

    The browser checks things such as:

    Is it expired?
    Is the domain name covered?
    Is the signature valid?
    Is the issuer trusted?
    Is the certificate chain valid?

    39. Domain Name Validation

    Suppose you visit:

    https://example.com

    but the certificate is only valid for:

    otherdomain.com

    The browser should reject it or display a certificate warning.


    40. Why SNI Exists

    Imagine one server has:

    example.com
    shop.example.com
    learn.example.com

    all using:

    IP address:
    203.0.113.25

    How does the server know which certificate the client wants?

    The browser sends:

    SNI

    Server Name Indication.


    41. SNI

    The browser effectively indicates:

    I am connecting to:
    
    learn.example.com

    during the TLS handshake.

    Nginx can then select the appropriate server configuration and certificate.


    42. One IP, Many HTTPS Websites

    This is fundamental to hosting.

    You can have:

    203.0.113.25
    │
    ├── example.com
    ├── shop.example.com
    ├── learn.example.com
    └── anotherdomain.com

    All using port:

    443

    SNI helps the server determine which hostname the client requested.


    43. Nginx Server Blocks

    You may have configurations like:

    server {
        listen 443 ssl;
        server_name example.com;
    
        ssl_certificate ...;
        ssl_certificate_key ...;
    }

    and:

    server {
        listen 443 ssl;
        server_name shop.example.com;
    
        ssl_certificate ...;
        ssl_certificate_key ...;
    }

    Both can listen on:

    443

    because Nginx uses the hostname and connection information to select the appropriate configuration.


    44. Private Key

    Nginx needs access to the private key.

    Conceptually:

    Nginx
     ├── certificate
     └── private key

    The private key must have appropriate permissions.


    45. Never Publish the Private Key

    Do not put:

    private key

    inside:

    public_html
    public/
    wp-content/

    It must remain outside publicly served directories.


    46. Public vs Private

    For a typical certificate:

    Certificate
    =
    public information
    Private key
    =
    secret

    This distinction is critical.


    47. Let’s Encrypt Files

    Certbot installations commonly use locations under:

    /etc/letsencrypt/

    For example:

    /etc/letsencrypt/live/example.com/

    The exact file structure depends on the ACME client and configuration.


    48. Common Certificate Files

    You may encounter:

    fullchain.pem
    cert.pem
    privkey.pem
    chain.pem

    Conceptually:

    cert.pem
    =
    website certificate
    
    chain.pem
    =
    intermediate chain
    
    fullchain.pem
    =
    certificate + intermediate chain
    
    privkey.pem
    =
    private key

    49. Nginx Configuration

    A common Nginx configuration looks conceptually like:

    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

    The exact configuration generated by your certificate tooling can vary.


    50. Why fullchain.pem?

    The browser needs to be able to build the certificate chain.

    Sending the website certificate plus required intermediate certificate(s) helps the client validate the chain.


    51. Certificate Expiration

    Certificates have a validity period.

    Let’s Encrypt certificates are intentionally short-lived.

    This is why:

    Automatic Renewal

    is essential.


    52. Why Short-Lived Certificates?

    Short-lived certificates reduce the period during which a compromised or otherwise problematic certificate remains valid.

    But the trade-off is:

    short validity
     ↓
    frequent renewal
     ↓
    automation required

    53. Renewal

    Your server needs a process that periodically checks whether certificates need renewal.

    For example:

    Certificate
     ↓
    approaching renewal window
     ↓
    ACME client
     ↓
    renew
     ↓
    update certificate
     ↓
    reload Nginx

    54. Renewal Failure

    If automation fails repeatedly:

    certificate expires
     ↓
    browser warning
     ↓
    website HTTPS problem

    This is why SSL monitoring matters in hosting.


    55. Test Certificate

    You can use:

    openssl s_client -connect example.com:443 -servername example.com

    This gives detailed TLS information.


    56. Why -servername?

    This option sends SNI.

    For a multi-domain server, that matters.

    Without SNI, you may inspect the wrong certificate or default server configuration.


    57. curl TLS Testing

    You can also use:

    curl -Iv https://example.com

    This provides useful TLS and HTTP diagnostics.


    58. Certificate Inspection

    You can inspect a certificate using OpenSSL.

    Conceptually:

    openssl s_client -connect example.com:443 -servername example.com

    Then inspect the certificate chain and TLS negotiation.


    59. TLS and HTTP Separation

    This is important:

    TLS
    =
    security layer
    HTTP
    =
    application protocol

    TLS doesn’t replace HTTP.

    It protects HTTP.


    60. HTTPS Request

    Once TLS is established:

    Encrypted connection
            ↓
    GET /about/
            ↓
    Nginx

    The HTTP request is carried inside the TLS-protected connection.


    61. What Does an Observer See?

    A network observer may be able to see metadata such as:

    source IP
    destination IP
    destination port
    traffic timing
    traffic size patterns

    But properly configured TLS prevents them from simply reading the HTTP request and response contents.

    TLS does not make all metadata invisible.


    62. HTTPS Does Not Hide the IP Address

    Suppose:

    example.com
     ↓
    203.0.113.25

    The network still needs to route traffic to the IP.

    So:

    HTTPS
    ≠
    anonymous

    It primarily protects the contents and authenticates the endpoint through the TLS system.


    63. HTTPS Does Not Protect a Compromised Server

    Suppose:

    WordPress
     ↓
    malware

    TLS can still be functioning perfectly.

    TLS protects communication between client and server.

    It does not automatically secure the application itself.


    64. HTTPS vs Website Security

    These are different:

    TLS security

    versus:

    WordPress security

    You need both.


    65. TLS Certificate vs Domain Ownership

    A certificate doesn’t mean:

    The domain belongs to this company in a legal/business sense.

    It means the CA validated control of the domain according to the certificate issuance process and issued a certificate.

    This distinction matters.


    66. Certificate Warning

    If the browser says:

    Your connection is not private

    possible causes include:

    expired certificate
    wrong hostname
    untrusted issuer
    incomplete chain
    certificate mismatch
    incorrect system time
    TLS configuration issue

    67. Wrong Certificate on Multi-Domain Server

    Suppose:

    example.com
    shop.example.com
    learn.example.com

    all share one IP.

    But the browser receives:

    example.com certificate

    when visiting:

    shop.example.com

    Then the hostname doesn’t match.

    Possible causes:

    incorrect SNI handling
    wrong Nginx server block
    certificate configuration
    default server selection

    68. This Is Why server_name Matters

    Nginx:

    server_name shop.example.com;

    tells Nginx which hostname this server block handles.


    69. HTTP to HTTPS Redirect

    Many websites run:

    HTTP :80

    and redirect to:

    HTTPS :443

    Conceptually:

    http://example.com
           ↓
    301
           ↓
    https://example.com

    70. Why Keep Port 80?

    You might ask:

    If HTTPS is secure, why use port 80 at all?

    Because HTTP can be used to:

    redirect to HTTPS
    perform HTTP-01 ACME validation
    serve legacy traffic if intentionally configured

    Many sites keep port 80 open solely for redirect/validation purposes.


    71. Nginx Example

    Conceptually:

    server {
        listen 80;
        server_name example.com;
    
        return 301 https://$host$request_uri;
    }

    Then HTTPS:

    server {
        listen 443 ssl;
        server_name example.com;
    
        ...
    }

    72. What Happens During a Normal HTTPS Visit?

    Let’s trace it.

    User types:

    https://learn.cresignsys.com

    Step 1

    DNS:

    learn.cresignsys.com
     ↓
    IP

    Step 2

    TCP:

    client
     ↓
    server:443

    Step 3

    TCP handshake:

    SYN
    SYN-ACK
    ACK

    Step 4

    TLS handshake:

    ClientHello
    ServerHello
    Certificate
    key establishment

    Step 5

    Secure session:

    encrypted channel

    Step 6

    HTTP:

    GET /
    Host: learn.cresignsys.com

    Step 7

    Nginx:

    server_name
     ↓
    location
     ↓
    WordPress/PHP

    73. The Complete Secure Web Stack

    You can now visualize:

    Browser
       │
       ▼
    DNS
       │
       ▼
    IP
       │
       ▼
    TCP
       │
       ▼
    TLS
       │
       ▼
    HTTP
       │
       ▼
    Nginx
       │
       ▼
    PHP-FPM
       │
       ▼
    WordPress
       │
       ▼
    MySQL

    74. Your SSL Automation Architecture

    For your CresignSys hosting platform, eventually:

    New Domain
        ↓
    DNS configured
        ↓
    Nginx HTTP server
        ↓
    ACME challenge
        ↓
    Let's Encrypt
        ↓
    Certificate
        ↓
    Private key
        ↓
    Nginx HTTPS configuration
        ↓
    nginx -t
        ↓
    reload
        ↓
    HTTPS test

    Then:

    Renewal
     ↓
    certificate replacement
     ↓
    Nginx reload

    75. A Very Important Security Rule

    Never do this:

    private key
     ↓
    public/
     ↓
    Internet

    Correct:

    private key
     ↓
    restricted filesystem location
     ↓
    Nginx

    76. Another Important Rule

    Don’t disable TLS verification just because something isn’t working.

    For example, avoid treating:

    curl -k https://example.com

    as a real fix.

    -k tells curl to skip certificate verification.

    It can be useful for controlled diagnostics, but it should not be used to hide a real certificate problem.


    77. TLS Troubleshooting

    If HTTPS fails:

    1. DNS correct?
    2. TCP 443 reachable?
    3. Nginx listening?
    4. Correct server_name?
    5. Correct certificate?
    6. Certificate not expired?
    7. Correct private key?
    8. Correct chain?
    9. TLS configuration valid?
    10. Nginx reload successful?

    78. Useful Commands

    Check Nginx

    sudo nginx -t

    Check port 443

    sudo ss -ltnp | grep ':443'

    Check certificate/TLS

    openssl s_client -connect example.com:443 -servername example.com

    Check HTTPS

    curl -Iv https://example.com

    Check certificate files

    sudo ls -la /etc/letsencrypt/live/

    79. Certificate Renewal Architecture

    Think:

    Certificate
         │
         ▼
    Expiration date
         │
         ▼
    Renewal process
         │
         ▼
    ACME challenge
         │
         ▼
    New certificate
         │
         ▼
    Nginx reload
         │
         ▼
    HTTPS continues

    A hosting service must monitor this lifecycle.


    80. The Most Important Vocabulary

    Memorize:

    TLS
    =
    Transport Layer Security
    
    HTTPS
    =
    HTTP over TLS
    
    Certificate
    =
    signed identity/public-key information
    
    Public key
    =
    shareable cryptographic key
    
    Private key
    =
    secret cryptographic key
    
    CA
    =
    Certificate Authority
    
    SNI
    =
    Server Name Indication
    
    SAN
    =
    Subject Alternative Name
    
    ACME
    =
    protocol used for automated certificate issuance/renewal
    
    Let's Encrypt
    =
    publicly trusted certificate authority providing automated certificates

    81. The Three Security Questions

    Whenever you think about HTTPS, remember:

    Confidentiality

    Can someone read the data?

    Integrity

    Can someone modify the data without detection?

    Authentication

    Am I communicating with the intended server/domain?

    TLS addresses these through cryptographic protocols and certificate-based authentication.


    82. One Complete Example

    Suppose:

    shop.cresignsys.com

    points to:

    your VPS

    The user visits:

    https://shop.cresignsys.com

    The chain is:

    DNS
     ↓
    VPS public IP
     ↓
    TCP 443
     ↓
    TLS handshake
     ↓
    certificate for shop.cresignsys.com
     ↓
    secure session
     ↓
    HTTP request
     ↓
    Nginx server block
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL

    Every layer has a separate responsibility.


    83. What You Have Learned

    Your complete understanding is now:

    DOMAIN
       ↓
    DNS
       ↓
    IP
       ↓
    TCP
       ↓
    TLS
       ↓
    HTTP
       ↓
    NGINX
       ↓
    PHP-FPM
       ↓
    WORDPRESS
       ↓
    MYSQL
       ↓
    INNODB
       ↓
    BUFFER POOL
       ↓
    DISK

    This is the core architecture behind the type of WordPress hosting system you are building.


    Lesson 049 Summary

    The key idea:

    TCP creates the transport connection; TLS secures it; HTTP carries the web request.

    So:

    TCP
     ↓
    TLS
     ↓
    HTTP

    And HTTPS:

    HTTPS
    =
    HTTP
    +
    TLS

    For your hosting platform, SSL automation is:

    Domain
     ↓
    ACME validation
     ↓
    Let's Encrypt
     ↓
    Certificate
     ↓
    Nginx
     ↓
    443
     ↓
    HTTPS

    Next Lesson — 050

    DNS Deep Internals — From Domain Name to Your VPS

    We will go deeper into:

    Domain
     ↓
    Registrar
     ↓
    Nameserver
     ↓
    Root DNS
     ↓
    TLD DNS
     ↓
    Authoritative DNS
     ↓
    A / AAAA
     ↓
    CNAME
     ↓
    MX
     ↓
    TXT
     ↓
    TTL
     ↓
    DNS cache
     ↓
    Your VPS

    Then we will connect it directly to your domains such as:

    cresignsys.com
    learn.cresignsys.com
    shop.cresignsys.com

    and explain exactly why changing DNS does not immediately change what every user sees, how propagation really works, and how to diagnose DNS problems from the command line.

  • CresignSys Learn — Lesson 048

    TCP/IP From the Absolute Basics

    We now go one level deeper into the network.

    You already know:

    Browser
     ↓
    DNS
     ↓
    IP
     ↓
    Internet
     ↓
    VPS
     ↓
    Port 443
     ↓
    Nginx

    But what actually happens when your browser connects to:

    learn.cresignsys.com:443

    The key technology is:

    TCP


    1. What Is TCP?

    TCP means:

    Transmission Control Protocol

    TCP provides reliable, ordered communication between applications over an IP network.

    Think:

    Application
         ↓
        TCP
         ↓
         IP
         ↓
     Network

    2. IP vs TCP

    These two solve different problems.

    IP

    Answers:

    Where should this packet go?

    TCP

    Answers:

    How can two applications communicate reliably?

    So:

    IP
    =
    addressing + routing
    TCP
    =
    reliable transport

    3. Simple Example

    Suppose:

    Your computer
    IP = A
    
    VPS
    IP = B

    You want:

    A → B

    IP provides the addressing.

    TCP provides the connection between applications.


    4. Port Numbers

    Suppose your VPS has:

    IP:
    203.0.113.25

    and Nginx listens on:

    443

    The destination becomes:

    203.0.113.25:443

    This identifies the destination network endpoint.


    5. TCP Connection

    TCP is connection-oriented.

    Before normal application data is exchanged, TCP establishes a connection.

    The classic process is called:

    Three-Way Handshake

    Client
      │
      │ SYN
      ▼
    Server
      │
      │ SYN-ACK
      ▼
    Client
      │
      │ ACK
      ▼
    Server

    Then application data can flow.


    6. SYN

    SYN means:

    Synchronize

    The client essentially says:

    I want to establish a TCP connection.

    Conceptually:

    Client → Server
    SYN

    7. SYN-ACK

    The server responds:

    Server → Client
    SYN + ACK

    Meaning approximately:

    I received your connection request, and I also want to establish the connection.


    8. ACK

    The client responds:

    Client → Server
    ACK

    Now the TCP connection is established.


    9. Complete Handshake

    Client                         Server
      │                              │
      │ -------- SYN -------------> │
      │                              │
      │ <------ SYN + ACK ---------- │
      │                              │
      │ -------- ACK -------------> │
      │                              │
      │       CONNECTION READY       │
      │                              │

    10. Why Three Messages?

    TCP needs both sides to establish that communication parameters can be synchronized.

    It isn’t simply:

    Client → Hello
    Server → Okay

    TCP establishes state on both endpoints.


    11. TCP Is Stateful

    TCP maintains connection state.

    For example:

    LISTEN
    SYN-SENT
    SYN-RECEIVED
    ESTABLISHED
    FIN-WAIT
    TIME-WAIT
    CLOSED

    These states help TCP manage connections correctly.


    12. Server Listening

    Before your browser connects:

    Nginx
     ↓
    TCP port 443
     ↓
    LISTEN

    Nginx has a listening socket.

    You can inspect it:

    sudo ss -ltnp

    13. Client Connects

    Browser:

    Client
     ↓
    destination:
    server-ip:443

    The operating system sends a TCP SYN.


    14. Server Receives SYN

    The server’s networking stack receives it.

    If:

    port 443

    is open and a service is listening:

    SYN
     ↓
    TCP stack
     ↓
    Nginx socket

    The server can respond.


    15. What If Port 443 Is Blocked?

    Suppose OCI security rules block:

    TCP 443

    Then the TCP handshake cannot complete normally.

    The request may appear to:

    timeout

    rather than reaching Nginx.


    16. What If Nothing Is Listening?

    Suppose:

    OCI allows 443
    Ubuntu firewall allows 443

    but:

    Nginx
     ↓
    not listening

    The behavior may be different from a silent firewall drop; the host can reject the connection with TCP RST.

    This distinction is useful during troubleshooting.


    17. Timeout vs Refused

    A simplified distinction:

    Timeout

    Often indicates:

    packet dropped
    firewall
    routing problem
    network problem

    Connection refused

    Often indicates:

    host reachable
    but no service accepting that port

    These are clues, not absolute diagnoses.


    18. TCP Data

    Once connected:

    Client
       ↔
    Server

    data can flow in both directions.

    For HTTPS:

    Browser
       ↔
    Nginx

    19. TCP Segmentation

    Applications don’t necessarily send one giant network message.

    Large data can be divided into smaller TCP segments.

    Conceptually:

    Application data
     ↓
    TCP
     ↓
    Segment 1
    Segment 2
    Segment 3
    Segment 4

    20. Sequence Numbers

    TCP uses:

    Sequence Numbers

    They help TCP track the ordering of transmitted data.

    Imagine:

    Segment A
    Segment B
    Segment C

    If they arrive out of order:

    C
    A
    B

    TCP can use sequence information to reconstruct the correct byte stream.


    21. TCP Provides an Ordered Byte Stream

    Applications generally see:

    A B C D E F

    rather than worrying about individual IP packets.

    TCP handles much of the ordering and reliability underneath.


    22. Acknowledgements

    The receiver acknowledges received data.

    Conceptually:

    Sender
      │
      │ data
      ▼
    Receiver
      │
      │ ACK
      ▼
    Sender

    The acknowledgement tells the sender what data has been received successfully.


    23. Lost Packet

    Suppose:

    Segment 1 ✓
    Segment 2 ✗
    Segment 3 ✓

    TCP detects that something is missing through sequence/acknowledgement mechanisms.

    It can retransmit the missing data.


    24. Retransmission

    Conceptually:

    Sender
     ↓
    Segment 2
     ↓
    LOST

    Then:

    Sender
     ↓
    Segment 2 again
     ↓
    Receiver

    This is one reason TCP is called reliable.


    25. TCP Is Not Magic

    Retransmission has a cost.

    If packets are repeatedly lost:

    packet loss
     ↓
    retransmission
     ↓
    waiting
     ↓
    slower transfer

    So network quality affects performance.


    26. Latency

    Latency means delay.

    For example:

    Client → Server

    might take:

    20 ms

    while another server might take:

    200 ms

    Latency affects interactive applications.


    27. RTT

    RTT means:

    Round-Trip Time

    It measures approximately how long it takes for a signal to travel from one endpoint to the other and back.

    Example:

    Client
     ↓ 20 ms
    Server
     ↓ 20 ms
    Client

    RTT ≈:

    40 ms

    Actual measurement depends on conditions and tooling.


    28. Why RTT Matters for Websites

    Suppose a page requires many sequential network interactions.

    Higher RTT can increase total waiting time.

    Modern browsers and HTTP protocols reduce this through:

    connection reuse
    parallelism
    multiplexing
    caching

    but latency still matters.


    29. Bandwidth

    Bandwidth is different from latency.

    Bandwidth is roughly:

    How much data can be transferred per unit time.

    For example:

    100 Mbps
    1 Gbps
    10 Gbps

    30. Latency vs Bandwidth

    Think:

    Latency
    =
    How long does it take to get there?
    
    Bandwidth
    =
    How much can we transfer per second?

    A connection can have:

    high bandwidth
    +
    high latency

    or:

    low bandwidth
    +
    low latency

    They are different characteristics.


    31. Packet Loss

    Suppose:

    100 packets sent

    and:

    5 packets lost

    Packet loss =:

    5%

    TCP may retransmit lost data.

    But high packet loss can significantly hurt performance.


    32. Congestion

    Imagine many users send traffic through the same network path.

    Users
     │
     ├── Traffic
     ├── Traffic
     ├── Traffic
     └── Traffic
            ↓
        Network link

    If the link becomes congested:

    queues
     ↓
    delay
     ↓
    packet loss
     ↓
    TCP adaptation

    33. TCP Congestion Control

    TCP has mechanisms that adjust sending behavior based on network conditions.

    The broad goal is:

    Avoid overwhelming the network.

    Modern TCP implementations use sophisticated algorithms.


    34. Slow Start

    A TCP connection doesn’t normally begin by sending at the maximum possible rate immediately.

    It starts cautiously and increases its sending rate as conditions allow.

    This is commonly associated with:

    Slow Start


    35. Why Slow Start?

    Imagine a new connection immediately sending enormous amounts of traffic.

    If the network path can’t handle it:

    congestion
     ↓
    packet loss
     ↓
    retransmission
     ↓
    worse congestion

    Slow start helps discover available capacity.


    36. Congestion Window

    TCP maintains concepts such as:

    Congestion Window (cwnd)

    This influences how much unacknowledged data can be in flight.

    Simplified:

    small cwnd
     ↓
    careful sending
     ↓
    network appears healthy
     ↓
    increase

    37. Receive Window

    TCP also has:

    Receive Window

    This relates to how much data the receiver is currently prepared to accept.

    So TCP has to consider both:

    network capacity
    +
    receiver capacity

    38. Flow Control

    Flow control prevents a fast sender from overwhelming a slower receiver.

    Imagine:

    Sender
     ↓↓↓↓↓↓↓↓↓
    Receiver

    If the receiver cannot process data quickly enough, TCP’s flow-control mechanisms help regulate transmission.


    39. Congestion Control vs Flow Control

    Memorize:

    Flow control
    =
    protect receiver
    Congestion control
    =
    protect network

    They are different problems.


    40. TCP Ports

    A TCP connection is identified by endpoint information.

    Conceptually:

    Client IP
    Client Port
    Server IP
    Server Port
    Protocol

    The combination is often described as a:

    5-tuple

    For example:

    TCP
    192.0.2.10:53124
    203.0.113.25:443

    41. Why Client Ports Are Random-Looking

    Your browser doesn’t normally use port 443 as its local port.

    Instead it may use an ephemeral port such as:

    53124

    So:

    Client
    192.0.2.10:53124
            ↓
    Server
    203.0.113.25:443

    42. Server Port

    The server uses a well-known/service port:

    443

    Nginx listens there.


    43. Client Ephemeral Port

    The operating system chooses an available temporary port:

    53124

    This allows many simultaneous connections.

    For example:

    Client:53124 → Server:443
    Client:53125 → Server:443
    Client:53126 → Server:443

    44. Multiple Users

    Thousands of users can connect to the same:

    server:443

    because their source addresses and/or source ports differ.

    Conceptually:

    User A :50001 → Server :443
    User B :50002 → Server :443
    User C :50003 → Server :443

    45. TCP Connection State

    Your server can have many connections:

    sudo ss -tan

    You may see:

    ESTAB
    LISTEN
    TIME-WAIT
    SYN-SENT

    46. ESTABLISHED

    Means a TCP connection is established.

    Example:

    ESTAB
    client:53124
    server:443

    Data can flow.


    47. LISTEN

    Means a server socket is waiting for incoming connections.

    Example:

    LISTEN
    0.0.0.0:443

    Nginx can accept incoming connections there.


    48. SYN-SENT

    A client has sent a SYN and is waiting for the response.

    Conceptually:

    Client
     ↓
    SYN
     ↓
    waiting

    49. SYN-RECV

    The server has received a SYN and is in the process of completing the handshake.


    50. TCP Connection Closing

    TCP also needs to close connections properly.

    A simplified closing sequence involves:

    FIN
    ACK
    FIN
    ACK

    The exact sequence depends on which side initiates closure and the connection state.


    51. FIN

    FIN means approximately:

    I have finished sending data.

    Conceptually:

    Client → Server
    FIN

    52. ACK

    The other side acknowledges:

    Server → Client
    ACK

    The remaining direction can then close separately.

    This is why TCP is full-duplex.


    53. Full-Duplex

    TCP allows both sides to send data independently.

    Client
     ↑     ↓
     │     │
     TCP connection
     │     │
     ↓     ↑
    Server

    54. TIME_WAIT

    After a TCP connection closes, one side may enter:

    TIME_WAIT

    This is normal TCP behavior.

    You may see many:

    TIME-WAIT

    connections on a busy web server.


    55. Why TIME_WAIT Exists

    It helps ensure delayed packets from an old connection don’t interfere with a later connection using the same endpoint combination.

    It also allows the final connection termination process to complete safely.


    56. Don’t Automatically Treat TIME_WAIT as an Error

    Seeing:

    1000 TIME-WAIT

    doesn’t automatically mean the server is broken.

    It can simply indicate many short-lived TCP connections.


    57. HTTP/1.1

    Traditional HTTP/1.1 can reuse TCP connections through:

    Keep-Alive

    Instead of:

    Request
     ↓
    TCP connection
     ↓
    close
    
    Request
     ↓
    new TCP connection

    the browser can reuse a connection:

    TCP connection
     ↓
    Request 1
     ↓
    Request 2
     ↓
    Request 3
     ↓
    ...

    This reduces connection setup overhead.


    58. HTTP/2

    HTTP/2 goes further.

    It can multiplex multiple streams over a single TCP connection.

    Conceptually:

    One TCP connection
    │
    ├── Stream 1
    ├── Stream 2
    ├── Stream 3
    └── Stream 4

    This reduces the need for many separate connections.


    59. HTTP/3

    HTTP/3 changes the transport layer.

    Instead of TCP:

    HTTP/3
     ↓
    QUIC
     ↓
    UDP

    QUIC provides transport features above UDP.


    60. TCP vs UDP

    TCP:

    Connection-oriented
    Reliable
    Ordered
    Retransmission
    Flow control
    Congestion control

    UDP:

    Connectionless datagram transport
    No built-in TCP-style reliability
    No built-in ordering
    Lower protocol overhead

    UDP does not mean “unreliable network” in the broader sense; it means the transport protocol itself does not provide TCP’s reliability mechanisms.


    61. Why Does HTTP/3 Use UDP?

    QUIC implements modern transport features in user space over UDP.

    This allows:

    HTTP/3
     ↓
    QUIC
     ↓
    UDP

    with features such as:

    encryption
    multiplexing
    connection migration
    reliability

    62. But Your Current Website May Use TCP

    When you see:

    HTTPS

    it doesn’t automatically tell you whether the connection uses HTTP/1.1, HTTP/2, or HTTP/3.

    For HTTP/1.1 and HTTP/2:

    HTTP
     ↓
    TCP

    For HTTP/3:

    HTTP
     ↓
    QUIC
     ↓
    UDP

    63. TCP and TLS

    For traditional HTTPS:

    TCP
     ↓
    TLS
     ↓
    HTTP

    The order is conceptually:

    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP

    64. TCP Handshake Before TLS

    For a traditional TCP-based HTTPS connection:

    TCP handshake
          ↓
    TLS handshake
          ↓
    HTTP request

    So there are multiple negotiation stages.


    65. Complete HTTPS Connection

    Simplified:

    Browser
       │
       │ TCP SYN
       ▼
    Server
       │
       │ SYN-ACK
       ▼
    Browser
       │
       │ ACK
       ▼
    TCP established
       │
       ▼
    TLS handshake
       │
       ▼
    Encrypted connection
       │
       ▼
    HTTP request

    66. Why This Matters

    When debugging:

    HTTPS doesn't work

    you need to determine:

    TCP failure?
    TLS failure?
    HTTP failure?
    Application failure?

    These are different problems.


    67. Example: TCP Failure

    443 blocked

    Result:

    TLS never starts

    because TCP hasn’t been established.


    68. Example: TLS Failure

    Suppose:

    TCP 443 ✓
    TLS ✗

    Possible causes:

    certificate problem
    TLS configuration
    protocol incompatibility
    SNI/configuration issue

    69. Example: HTTP Failure

    Suppose:

    TCP ✓
    TLS ✓
    HTTP ✓

    but response is:

    500 Internal Server Error

    Now the network works.

    The problem is higher in the application/server stack.


    70. Example: WordPress Failure

    TCP ✓
    TLS ✓
    HTTP ✓
    Nginx ✓
    PHP-FPM ✓
    WordPress ✗

    You might get:

    500

    or a WordPress-specific error page.


    71. TCP Testing

    A useful test:

    nc -vz example.com 443

    If successful, you know the TCP port is reachable.

    But this doesn’t prove:

    TLS works
    HTTP works
    WordPress works

    It only tests the TCP connection at a basic level.


    72. curl -v

    For deeper HTTPS debugging:

    curl -v https://example.com/

    This can show stages of the connection, including:

    DNS resolution
    TCP connection
    TLS handshake
    HTTP request
    HTTP response

    73. Very Useful Command

    Try:

    curl -Iv https://example.com/

    This combines:

    -I

    headers only, and:

    -v

    verbose diagnostics.


    74. Local Server Test

    On the VPS:

    curl -I http://127.0.0.1

    This tests the local web server.

    If it works:

    Nginx is responding locally

    but external access fails:

    look at networking/firewall/cloud rules

    75. Binding Address Matters

    Suppose Nginx listens on:

    127.0.0.1:443

    Then only local connections can normally reach that socket.

    If it listens on:

    0.0.0.0:443

    it can accept IPv4 connections on the configured interfaces.

    This is a major troubleshooting clue.


    76. Check Nginx Listening Address

    Run:

    sudo ss -ltnp | grep ':443'

    Look at the local address.

    For example:

    0.0.0.0:443

    versus:

    127.0.0.1:443

    They mean very different things.


    77. TCP and Your Hosting Platform

    When you create a website automatically, your platform needs to make sure:

    DNS
     ↓
    public IP
     ↓
    TCP 80/443
     ↓
    Nginx
     ↓
    website

    is correctly configured.


    78. Hosting Automation

    Your future hosting script might perform:

    Create website
           ↓
    Create directory
           ↓
    Create Nginx config
           ↓
    Enable config
           ↓
    Reload Nginx
           ↓
    Install SSL
           ↓
    Verify port 443
           ↓
    Test HTTPS

    A good automation script should verify each stage.


    79. Don’t Assume

    For example, after:

    sudo systemctl reload nginx

    don’t assume:

    website works

    Instead test:

    sudo nginx -t
    sudo ss -ltnp | grep ':443'
    curl -I https://example.com

    80. Network Troubleshooting Tree

    If website doesn’t load:

    DNS?
     │
     ├── NO → fix DNS
     │
     └── YES
           ↓
    TCP 443?
     │
     ├── NO → routing/firewall/listener
     │
     └── YES
           ↓
    TLS?
     │
     ├── NO → certificate/TLS config
     │
     └── YES
           ↓
    HTTP?
     │
     ├── NO → Nginx/application
     │
     └── YES
           ↓
    WordPress?
     │
     ├── NO → PHP/database/application
     │
     └── YES → working

    81. Deep Mental Model

    You should now visualize:

    APPLICATION
        │
        ▼
       HTTP
        │
        ▼
       TLS
        │
        ▼
       TCP
        │
        ▼
        IP
        │
        ▼
     Network Interface
        │
        ▼
       Internet

    On the receiving side:

    Internet
       │
       ▼
    Network Interface
       │
       ▼
    IP
       │
       ▼
    TCP
       │
       ▼
    TLS
       │
       ▼
    HTTP
       │
       ▼
    Nginx

    82. One Critical Principle

    Each layer has a different job.

    DNS
    =
    name → address
    
    IP
    =
    routing/addressing
    
    TCP
    =
    reliable transport
    
    TLS
    =
    encryption/authentication
    
    HTTP
    =
    web application protocol
    
    Nginx
    =
    web server

    Do not mix them together.


    83. The Full CresignSys Hosting Stack

    You now have:

                        DOMAIN
                           │
                           ▼
                          DNS
                           │
                           ▼
                     PUBLIC IP
                           │
                           ▼
                     INTERNET ROUTING
                           │
                           ▼
                      OCI VCN
                           │
                           ▼
                        SUBNET
                           │
                           ▼
                         VNIC
                           │
                           ▼
                        UBUNTU
                           │
                  ┌────────┴────────┐
                  ▼                 ▼
               FIREWALL          SERVICES
                                    │
                                    ▼
                                  NGINX
                                    │
                                   TLS
                                    │
                                   HTTP
                                    │
                               PHP-FPM
                                    │
                                WORDPRESS
                                    │
                                 MySQL
                                    │
                                 InnoDB
                                    │
                                  DISK

    This is becoming your complete server mental model.


    84. Commands to Practice

    Run these on your Ubuntu VPS.

    Network interfaces

    ip addr

    Routing

    ip route

    Listening ports

    sudo ss -ltnp

    All TCP connections

    sudo ss -tan

    DNS

    dig +short yourdomain.com

    HTTP

    curl -I http://yourdomain.com

    HTTPS

    curl -Iv https://yourdomain.com

    Firewall

    sudo ufw status

    Nginx

    sudo nginx -t

    85. What You Should Understand Now

    You should be able to explain:

    What happens when someone opens your website?

    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP
     ↓
    Nginx

    What happens after Nginx receives a PHP request?

    Nginx
     ↓
    FastCGI
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL

    Where does the network stop?

    Internet
     ↓
    VNIC
     ↓
    Ubuntu

    Where does application processing begin?

    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress

    Lesson 048 Summary

    The essential concepts:

    TCP
    =
    reliable transport protocol
    
    SYN
    =
    request to establish TCP connection
    
    SYN-ACK
    =
    server response to SYN
    
    ACK
    =
    acknowledgement
    
    Sequence number
    =
    helps maintain byte ordering
    
    Retransmission
    =
    resends missing data
    
    RTT
    =
    round-trip time
    
    Latency
    =
    delay
    
    Bandwidth
    =
    transfer capacity
    
    Flow control
    =
    protect receiver
    
    Congestion control
    =
    manage network congestion
    
    Port
    =
    service endpoint
    
    Socket
    =
    communication endpoint
    
    LISTEN
    =
    waiting for connections
    
    ESTABLISHED
    =
    active TCP connection
    
    TIME_WAIT
    =
    normal post-connection TCP state

    The most important flow to memorize:

    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL

    Next Lesson — 049

    TLS/HTTPS From the Absolute Basics

    We will go inside the part between TCP and HTTP:

    TCP
     ↓
    TLS
     ↓
    HTTPS

    and learn:

    What is encryption?
    What is a certificate?
    What is a private key?
    What is a public key?
    What is a CA?
    What is Let's Encrypt?
    What is a certificate chain?
    What is TLS handshake?
    What is SNI?
    Why does Nginx need SSL configuration?
    Why does a certificate work for one domain but not another?

    Then we will connect it directly to your Let’s Encrypt + Nginx + multiple-domain hosting setup.

  • CresignSys Learn — Lesson 047

    Linux Networking From the Absolute Basics

    We now move underneath Nginx.

    So far you understand:

    Browser
     ↓
    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL

    But an important question remains:

    How does the Internet actually reach your Ubuntu VPS?

    The answer involves:

    Network Interface
    IP Address
    MAC Address
    Subnet
    Gateway
    Routing
    Ports
    Sockets
    TCP
    UDP
    Firewall
    VNIC
    Cloud Security Rules

    1. Start With the Simplest Idea

    A network allows computers to communicate.

    For example:

    Computer A
        │
        │ network
        ▼
    Computer B

    On the Internet:

    Your Browser
         │
         ▼
    Internet
         │
         ▼
    Your VPS

    2. Your VPS Is a Computer

    Your Oracle Cloud VM is simply a computer running remotely.

    Conceptually:

    Oracle Cloud VM
    │
    ├── CPU
    ├── RAM
    ├── Disk
    ├── Network interface
    └── Ubuntu

    The network interface connects the VM to the network.


    3. Network Interface

    A network interface is the component through which the operating system communicates over a network.

    On Linux you may see interfaces such as:

    ens3
    eth0
    lo

    The exact name depends on the system.


    4. lo

    You will commonly see:

    lo

    This means:

    Loopback

    It represents the local machine itself.

    Its common IPv4 address is:

    127.0.0.1

    5. What Is 127.0.0.1?

    When a program connects to:

    127.0.0.1

    it is communicating with the same machine.

    For example:

    Nginx
     ↓
    127.0.0.1
     ↓
    local service

    No external Internet connection is required.


    6. Why This Matters to Your Server

    Your server may have:

    Nginx
    PHP-FPM
    MySQL

    all running on the same VM.

    They can communicate locally.

    For example:

    WordPress
     ↓
    MySQL

    may use:

    localhost

    instead of going through the public Internet.


    7. IP Address

    An IP address identifies a network endpoint.

    Example IPv4:

    203.0.113.25

    IPv4 has four numeric sections.

    Conceptually:

    203 . 0 . 113 . 25

    Each section is an octet.


    8. Private vs Public IP

    An IP can be:

    Public

    or:

    Private

    A public IP is reachable through the public Internet subject to routing and firewall rules.

    A private IP is intended for private network communication.


    9. Private IPv4 Ranges

    Common private IPv4 ranges include:

    10.0.0.0/8
    
    172.16.0.0/12
    
    192.168.0.0/16

    For example:

    10.0.0.15

    is a private address.


    10. Your Cloud VM

    A cloud VM commonly has a private address inside the cloud network.

    It may also have a public IP associated with its networking configuration.

    Conceptually:

    Internet
       ↓
    Public IP
       ↓
    Cloud networking
       ↓
    Private IP
       ↓
    Ubuntu VM

    The exact Oracle Cloud networking configuration determines the details.


    11. VNIC

    In Oracle Cloud, a VM uses a:

    VNIC

    Virtual Network Interface Card.

    Think of it as the VM’s virtual network adapter.

    Conceptually:

    Oracle Cloud VM
          │
          ▼
         VNIC
          │
          ▼
    Virtual Cloud Network

    12. VCN

    Oracle Cloud uses:

    VCN — Virtual Cloud Network

    It provides the networking environment for your cloud resources.

    Conceptually:

    VCN
    │
    ├── Subnet
    ├── Route table
    ├── Security rules
    └── Network resources

    13. Subnet

    A subnet is a logical portion of an IP network.

    Imagine:

    VCN
    │
    └── Subnet
          │
          ├── VM A
          ├── VM B
          └── VM C

    Each resource gets an IP address appropriate to that subnet.


    14. CIDR

    You will frequently see something like:

    10.0.0.0/24

    This is CIDR notation.

    CIDR means:

    Classless Inter-Domain Routing


    15. Understanding /24

    For:

    10.0.0.0/24

    the /24 means the first 24 bits represent the network portion.

    The remaining 8 bits represent host addresses.

    A /24 contains:

    256 total IPv4 addresses

    although not every address is necessarily assignable to a host depending on the networking environment.


    16. /16

    For example:

    10.0.0.0/16

    has:

    65,536 total IPv4 addresses

    Again, usable host allocation depends on the network platform and reserved addresses.


    17. Why CIDR Matters

    Suppose your VM has:

    10.0.0.25

    and the subnet is:

    10.0.0.0/24

    The system knows that:

    10.0.0.x

    belongs to the local subnet.


    18. Network and Host

    For:

    10.0.0.25/24

    conceptually:

    Network:
    10.0.0.0
    
    Host:
    25

    The actual binary calculation is what determines this.


    19. Binary

    Computers ultimately work with bits.

    An IPv4 address is:

    32 bits

    For example:

    10.0.0.25

    is represented internally as four 8-bit values.


    20. Why Learn Binary?

    You don’t need to convert every address manually.

    But understanding binary helps explain:

    subnets
    CIDR
    routing
    network masks
    IP ranges

    21. Subnet Mask

    The /24 corresponds to:

    255.255.255.0

    So:

    10.0.0.25/24

    can also be represented as:

    10.0.0.25
    255.255.255.0

    22. Default Gateway

    Suppose your VM wants to communicate outside its local subnet.

    It needs a route toward the outside network.

    This commonly involves a:

    Default Gateway

    Conceptually:

    VM
     ↓
    Default Gateway
     ↓
    Internet

    23. Routing

    Routing answers:

    Where should this packet go next?

    Imagine:

    VM
     ↓
    Router A
     ↓
    Router B
     ↓
    Router C
     ↓
    Destination

    Each router makes forwarding decisions.


    24. Routing Table

    Linux maintains a routing table.

    Check it with:

    ip route

    You might see something conceptually like:

    default via 10.0.0.1 dev ens3
    10.0.0.0/24 dev ens3

    The exact output on your VM will differ.


    25. Meaning of default

    A route such as:

    default via 10.0.0.1

    means approximately:

    For destinations that don’t match a more specific route, send traffic through this gateway.


    26. More Specific Routes Win

    Suppose:

    10.0.0.0/24

    and:

    default

    both exist.

    For destination:

    10.0.0.50

    the /24 route is more specific.

    So Linux uses it instead of the default route.


    27. Routing Example

    Imagine:

    Destination:
    10.0.0.50

    Linux checks:

    Do I have a route for 10.0.0.0/24?

    Yes.

    So:

    send through local interface

    28. Internet Destination

    Now:

    Destination:
    8.8.8.8

    If there isn’t a more specific route:

    8.8.8.8
     ↓
    default route
     ↓
    gateway

    29. ip addr

    To inspect network interfaces:

    ip addr

    or:

    ip a

    You’ll see:

    lo
    ens3

    and IP addresses associated with them.


    30. Example

    Conceptually:

    2: ens3:
        inet 10.0.0.25/24

    This means the interface has:

    IP:
    10.0.0.25
    
    Prefix:
    24

    31. ip link

    To inspect interfaces:

    ip link

    This shows information about network links.


    32. Interface State

    You might see:

    state UP

    or:

    state DOWN

    If the interface is down, networking through that interface won’t work normally.


    33. MAC Address

    Network interfaces have a:

    MAC address

    Example format:

    02:42:ac:11:00:02

    A MAC address operates at the data-link layer.

    It is different from an IP address.


    34. IP vs MAC

    Think:

    IP
    =
    logical network addressing
    MAC
    =
    link-layer interface address

    Simplified:

    IP
     ↓
    Where is the destination?
    
    MAC
     ↓
    Which local network interface?

    35. Ethernet

    On traditional local networks, devices communicate using Ethernet frames.

    Conceptually:

    Application
     ↓
    TCP
     ↓
    IP
     ↓
    Ethernet
     ↓
    Network interface

    36. Packets vs Frames

    A useful distinction:

    IP
    =
    packet
    Ethernet
    =
    frame

    The terminology changes by networking layer.


    37. ARP

    For IPv4 local networks, a system may need to discover:

    Which MAC address corresponds to this local IP?

    This involves:

    ARP

    Address Resolution Protocol.

    Conceptually:

    IP address
     ↓
    ARP
     ↓
    MAC address

    38. Example

    Suppose your machine needs to communicate with:

    10.0.0.1

    It may ask:

    Who has 10.0.0.1?

    The device using that IP can respond with its MAC address.


    39. Cloud Networking Is More Abstract

    In Oracle Cloud, you don’t manually manage physical Ethernet switches.

    OCI provides virtualized networking.

    So you should think:

    Physical infrastructure
           ↓
    OCI virtualization
           ↓
    VNIC
           ↓
    VCN
           ↓
    Subnet
           ↓
    VM

    40. Port

    An IP address identifies a network endpoint.

    A:

    Port

    identifies a service endpoint on that host.

    For example:

    203.0.113.25:443

    means:

    IP:
    203.0.113.25
    
    Port:
    443

    41. Why Ports Exist

    One server can run many services.

    For example:

    Server
    │
    ├── SSH :22
    ├── HTTP :80
    ├── HTTPS :443
    ├── MySQL :3306
    └── Other services

    The port tells the operating system which application should receive the connection.


    42. Port 22

    Usually:

    22
    =
    SSH

    You use SSH to administer your server.


    43. Port 80

    Usually:

    80
    =
    HTTP

    Your web server listens here for ordinary HTTP traffic.


    44. Port 443

    Usually:

    443
    =
    HTTPS

    Your HTTPS websites normally use this port.


    45. Port 3306

    Conventionally:

    3306
    =
    MySQL

    But MySQL can be configured to use another port.

    For security, a database usually should not be exposed publicly unless there is a specific reason and appropriate controls.


    46. Socket

    A socket is an endpoint for network communication.

    Conceptually:

    IP + Port + Protocol

    identifies a network communication endpoint.

    For example:

    10.0.0.25:443

    47. Server Listening

    When Nginx is configured for HTTPS:

    Nginx
     ↓
    listen
     ↓
    443

    It opens a listening socket.

    Conceptually:

    0.0.0.0:443

    means listening on port 443 on all suitable IPv4 interfaces.


    48. ss

    A very useful Linux networking command is:

    ss -tulpn

    It can show listening TCP/UDP sockets and associated processes, subject to permissions.


    49. Example

    You may see:

    LISTEN
    0.0.0.0:22

    meaning SSH is listening on IPv4 port 22.

    And:

    LISTEN
    0.0.0.0:80

    meaning something such as Nginx is listening on port 80.


    50. Check Web Ports

    You can use:

    sudo ss -ltnp

    This focuses on TCP listening sockets.

    Look for:

    :80
    :443

    51. If Nginx Is Running But Port 443 Is Missing

    Suppose:

    systemctl status nginx

    says:

    active (running)

    but:

    sudo ss -ltnp

    doesn’t show:

    :443

    Then HTTPS may not actually be configured/listening.

    This illustrates:

    Service running ≠ desired port listening.


    52. Firewall

    Now we reach another major layer.

    A firewall controls network traffic according to rules.

    Conceptually:

    Internet
       ↓
    Firewall
       ↓
    Server

    53. Firewall Rule

    A firewall might allow:

    TCP 22
    TCP 80
    TCP 443

    and block:

    TCP 3306

    from the public Internet.


    54. Why Multiple Firewall Layers Exist in Cloud Hosting

    Your traffic may encounter several security boundaries.

    Conceptually:

    Internet
     ↓
    OCI network security
     ↓
    VM network
     ↓
    Ubuntu firewall
     ↓
    Nginx

    So opening a port in only one layer may not be enough.


    55. Oracle Cloud Security Rules

    OCI networking can use security controls such as:

    Security Lists

    and:

    Network Security Groups

    These determine which traffic can reach resources according to the configured rules.

    The exact setup depends on your VCN/subnet design.


    56. Example HTTPS Rule

    You might configure an inbound rule allowing:

    Protocol:
    TCP
    
    Destination port:
    443
    
    Source:
    0.0.0.0/0

    Conceptually:

    Internet
     ↓
    TCP 443
     ↓
    allowed
     ↓
    VM

    57. What Does 0.0.0.0/0 Mean?

    It means:

    all IPv4 addresses

    So:

    Source = 0.0.0.0/0

    means the rule can apply to traffic originating from anywhere on IPv4, subject to the rest of the rule.


    58. Why SSH Should Be Treated Differently

    A common rule:

    TCP 22
    Source: 0.0.0.0/0

    allows SSH from anywhere on the Internet.

    That may be convenient, but it increases exposure.

    A stronger approach is to restrict SSH to trusted source IPs or use other controlled access mechanisms where practical.


    59. Web Ports Are Different

    For a public website:

    80
    443

    normally need to be reachable by Internet users.

    So:

    TCP 443
    Source:
    Internet

    is normal for a public HTTPS website.


    60. MySQL Should Usually Stay Private

    For a single-server WordPress installation:

    Internet
         X
         ↓
    MySQL :3306

    Instead:

    WordPress
     ↓
    localhost
     ↓
    MySQL

    There is usually no reason for the public Internet to connect directly to MySQL.


    61. Network Exposure

    Think about every listening service:

    SSH
    HTTP
    HTTPS
    MySQL
    PHP-FPM

    Ask:

    Does this service actually need to be reachable from the Internet?

    Usually:

    HTTP → yes
    HTTPS → yes
    SSH → controlled access
    MySQL → no
    PHP-FPM → no

    62. PHP-FPM Exposure

    If PHP-FPM uses:

    /run/php/php8.3-fpm.sock

    it isn’t exposed as a TCP Internet service.

    That’s good.

    If PHP-FPM were listening on a public interface unnecessarily, that would create additional exposure.


    63. Localhost Binding

    A service can sometimes be bound to:

    127.0.0.1

    rather than:

    0.0.0.0

    This means it only accepts local connections.

    For example:

    127.0.0.1:9000

    is not directly reachable from remote machines through the normal network path.


    64. 0.0.0.0

    When a service listens on:

    0.0.0.0:80

    it generally means it is listening on all IPv4 interfaces on port 80.

    That can include the public interface.


    65. 127.0.0.1

    When a service listens on:

    127.0.0.1:9000

    it is restricted to local IPv4 connections.

    This is an important security concept.


    66. IPv6

    Not all Internet traffic uses IPv4.

    There is also:

    IPv6

    An IPv6 address might look like:

    2001:db8::1234

    IPv6 addresses are 128 bits.


    67. Why IPv6 Matters

    A server may have:

    IPv4
    +
    IPv6

    If DNS publishes both:

    A record
    AAAA record

    some clients may connect using IPv6.


    68. A Record

    DNS:

    A

    maps a hostname to an IPv4 address.

    Example conceptually:

    example.com
     ↓
    A
     ↓
    203.0.113.25

    69. AAAA Record

    DNS:

    AAAA

    maps a hostname to an IPv6 address.

    Conceptually:

    example.com
     ↓
    AAAA
     ↓
    2001:db8::1234

    70. A Common IPv6 Mistake

    Suppose:

    A
     ↓
    correct IPv4

    but:

    AAAA
     ↓
    incorrect IPv6

    Some users may experience failures even though IPv4 works correctly.

    This is why IPv6 configuration should be deliberate.


    71. DNS vs Networking

    This distinction is extremely important.

    DNS answers:

    What IP address corresponds to this hostname?

    Networking answers:

    Can I actually reach that IP and service?

    So:

    DNS working

    does not guarantee:

    website working

    72. Example

    Suppose:

    example.com
     ↓
    203.0.113.25

    DNS is correct.

    But:

    TCP 443
     ↓
    blocked

    The website still won’t load.


    73. Another Example

    Suppose:

    TCP 443
     ↓
    allowed

    but:

    Nginx
     ↓
    not listening

    Still no working HTTPS website.


    74. Another Example

    Suppose:

    Nginx
     ↓
    443 listening

    but:

    TLS certificate/configuration
     ↓
    broken

    HTTPS can still fail.


    75. Another Example

    Suppose:

    HTTPS
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    broken

    The browser may receive:

    502

    So each layer must work.


    76. Full Connectivity Chain

    For:

    https://example.com

    you can think:

    1. DNS
    2. IP routing
    3. Cloud security rules
    4. Ubuntu networking/firewall
    5. TCP 443
    6. Nginx listening
    7. TLS
    8. HTTP
    9. Application

    77. Diagnostic Tool: ping

    You may know:

    ping example.com

    It tests ICMP reachability, not TCP/HTTPS specifically.

    A server can block ICMP and still serve HTTPS perfectly.

    Therefore:

    Ping failure does not automatically mean the website is down.


    78. curl

    For web testing, curl is much more useful.

    Example:

    curl -I https://example.com

    This asks for HTTP headers.

    You might receive:

    HTTP/2 200

    or:

    HTTP/2 301

    or:

    HTTP/2 502

    79. HTTP Status Codes

    Some important ones:

    200
    =
    Success
    
    301
    =
    Permanent redirect
    
    302
    =
    Temporary redirect
    
    403
    =
    Forbidden
    
    404
    =
    Not found
    
    500
    =
    Application/server error
    
    502
    =
    Bad gateway
    
    503
    =
    Service unavailable

    80. Test HTTP

    curl -I http://example.com

    Test HTTPS:

    curl -I https://example.com

    This lets you test from the server or another machine without relying on the browser UI.


    81. Test DNS

    dig example.com

    or:

    nslookup example.com

    You previously used:

    nslookup domain 8.8.8.8

    This checks DNS resolution through Google’s DNS resolver.


    82. Test Port Connectivity

    From another machine:

    nc -vz example.com 443

    This can test whether TCP port 443 is reachable.

    Alternatively:

    nc -vz example.com 80

    83. ss vs nc

    Remember:

    ss
    =
    what is listening locally?
    nc
    =
    can I connect to this remote port?

    So:

    Local diagnosis
     ↓
    ss

    and:

    Remote connectivity
     ↓
    nc

    84. curl vs nc

    nc tests TCP connectivity.

    curl goes further and tests the HTTP protocol.

    So:

    nc
    =
    Can I establish TCP?
    
    curl
    =
    Can I communicate using HTTP/HTTPS?

    85. A Practical Website Diagnostic

    Suppose:

    https://example.com

    doesn’t load.

    Use this order:

    DNS
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP
     ↓
    Nginx
     ↓
    PHP
     ↓
    WordPress
     ↓
    MySQL

    86. Step 1 — DNS

    dig +short example.com

    Confirm the expected IP.


    87. Step 2 — Local Port

    On the VPS:

    sudo ss -ltnp | grep ':443'

    Confirm something is listening.


    88. Step 3 — Local HTTP Test

    From the server:

    curl -I https://example.com

    If this works locally but not externally, suspect:

    cloud firewall
    routing
    security rules
    public IP
    DNS

    89. Step 4 — Nginx

    sudo systemctl status nginx

    Then:

    sudo nginx -t

    90. Step 5 — Logs

    sudo tail -f /var/log/nginx/error.log

    Then make a request.


    91. Step 6 — PHP-FPM

    systemctl status php8.3-fpm

    Replace the version appropriately.


    92. Step 7 — MySQL

    sudo systemctl status mysql

    Then verify database connectivity if necessary.


    93. This Is Layered Troubleshooting

    Never immediately change five configuration files.

    Instead:

    Question
     ↓
    Test
     ↓
    Evidence
     ↓
    Next layer

    For example:

    Does DNS resolve?
         ↓
    YES
         ↓
    Does TCP 443 connect?
         ↓
    YES
         ↓
    Does TLS work?
         ↓
    YES
         ↓
    Does Nginx respond?
         ↓
    YES
         ↓
    Does PHP work?

    This prevents random troubleshooting.


    94. Oracle Cloud Architecture

    Your environment can be visualized as:

                             INTERNET
                                │
                                ▼
                         Public IP / DNS
                                │
                                ▼
                        Oracle Cloud VCN
                                │
                                ▼
                             Subnet
                                │
                                ▼
                              VNIC
                                │
                                ▼
                          Ubuntu VM
                                │
                  ┌─────────────┼─────────────┐
                  ▼             ▼             ▼
                 SSH           Nginx        Other
                 :22           :80/:443     services
                                │
                                ▼
                           PHP-FPM
                                │
                                ▼
                             MySQL

    The actual OCI topology can be more detailed, but this is the foundational model.


    95. Cloud Security Layer

    Think:

    Internet
     ↓
    OCI security rules
     ↓
    VNIC
     ↓
    Ubuntu
     ↓
    local firewall
     ↓
    service

    A connection can be blocked before it reaches Nginx.


    96. Ubuntu Firewall

    Ubuntu systems may use:

    UFW

    Uncomplicated Firewall.

    Check:

    sudo ufw status

    You might see rules such as:

    22/tcp
    80/tcp
    443/tcp

    97. Important: UFW May Not Be Your Only Firewall

    Cloud security rules and UFW are separate layers.

    For example:

    OCI allows 443

    but:

    UFW blocks 443

    The connection can still fail.

    Likewise:

    UFW allows 443

    but:

    OCI blocks 443

    It can still fail.


    98. Two-Gate Model

    Think:

    Internet
       ↓
    [ OCI security ]
       ↓
    [ Ubuntu firewall ]
       ↓
    [ Nginx ]

    Traffic must pass all applicable controls.


    99. Why This Explains Many Hosting Problems

    Suppose you install Nginx correctly.

    Nginx ✓

    But forget cloud ingress:

    OCI security ✗

    Result:

    Website inaccessible

    You might incorrectly think:

    Nginx is broken.

    It isn’t.

    The packet never reached it.


    100. Another Example

    Suppose:

    OCI ✓
    UFW ✓
    Nginx ✗

    Then:

    TCP connection
     ↓
    Nginx unavailable

    The service layer is the problem.


    101. Another Example

    Suppose:

    OCI ✓
    UFW ✓
    Nginx ✓
    PHP-FPM ✗

    Then:

    Static files
     ↓
    may work
    
    PHP
     ↓
    502/error

    102. Another Example

    Suppose:

    Everything above works
     ↓
    MySQL ✗

    Then:

    WordPress
     ↓
    database error

    103. The Layer Model

    You should now start thinking like a server administrator:

    Layer 1
    DNS
    
    Layer 2
    Network routing
    
    Layer 3
    Cloud security
    
    Layer 4
    TCP/UDP
    
    Layer 5
    Ubuntu firewall
    
    Layer 6
    Nginx
    
    Layer 7
    TLS/HTTP
    
    Layer 8
    PHP-FPM
    
    Layer 9
    WordPress
    
    Layer 10
    MySQL

    This is a simplified operational model, not a strict OSI-layer mapping.


    104. Important Commands

    Start memorizing these:

    Network interfaces

    ip addr

    Routes

    ip route

    Listening services

    sudo ss -ltnp

    DNS

    dig example.com

    HTTP test

    curl -I https://example.com

    Firewall

    sudo ufw status

    Nginx

    sudo systemctl status nginx

    Nginx configuration

    sudo nginx -t

    105. One Powerful Mental Model

    When a user says:

    “My website is not opening.”

    Don’t immediately think:

    WordPress problem

    Think:

                        Website unavailable
                               │
                 ┌─────────────┼─────────────┐
                 ▼             ▼             ▼
                DNS          Network       Application
                 │             │             │
                 ▼             ▼             ▼
              IP correct?    Port 443?     Nginx?
                                           PHP?
                                           WordPress?
                                           MySQL?

    Then test each layer.


    106. The Full Journey

    A user types:

    https://learn.cresignsys.com

    The request travels conceptually:

    Browser
       │
       ▼
    DNS Resolver
       │
       ▼
    DNS authoritative infrastructure
       │
       ▼
    IP address
       │
       ▼
    Internet routers
       │
       ▼
    OCI network
       │
       ▼
    VCN
       │
       ▼
    Subnet
       │
       ▼
    VNIC
       │
       ▼
    Ubuntu
       │
       ▼
    TCP :443
       │
       ▼
    Nginx
       │
       ▼
    TLS
       │
       ▼
    HTTP
       │
       ▼
    PHP-FPM
       │
       ▼
    WordPress
       │
       ▼
    MySQL

    107. What You Have Learned So Far

    Your learning path has now reached:

    BASIC COMPUTER
          ↓
    Linux
          ↓
    Filesystem
          ↓
    Permissions
          ↓
    Networking
          ↓
    DNS
          ↓
    TCP/IP
          ↓
    TLS
          ↓
    HTTP
          ↓
    Nginx
          ↓
    PHP-FPM
          ↓
    WordPress
          ↓
    MySQL
          ↓
    InnoDB

    This is the foundation of your web-hosting server.


    108. Next Level

    The next major topic is:

    TCP/IP in Depth

    We have used TCP repeatedly, but haven’t yet studied what TCP actually does.

    We will go deeper into:

    TCP
    │
    ├── Connection
    ├── SYN
    ├── SYN-ACK
    ├── ACK
    ├── Sequence numbers
    ├── Acknowledgements
    ├── Retransmission
    ├── Flow control
    ├── Congestion control
    ├── Connection termination
    └── TIME_WAIT

    Then:

    TCP
     ↓
    443
     ↓
    TLS
     ↓
    HTTP

    will become completely understandable.


    Lesson 047 Summary

    The most important concepts:

    VNIC
    =
    virtual network interface
    
    VCN
    =
    virtual cloud network
    
    Subnet
    =
    logical IP network segment
    
    Gateway
    =
    next-hop router for traffic
    
    Routing table
    =
    rules determining where packets go
    
    IP
    =
    network-layer addressing
    
    MAC
    =
    link-layer addressing
    
    Port
    =
    service endpoint
    
    Socket
    =
    communication endpoint
    
    Firewall
    =
    traffic filtering
    
    UFW
    =
    Ubuntu firewall management tool
    
    A record
    =
    hostname → IPv4
    
    AAAA record
    =
    hostname → IPv6

    And the most important troubleshooting chain is:

    DNS
     ↓
    IP
     ↓
    Route
     ↓
    Cloud security
     ↓
    TCP port
     ↓
    Ubuntu firewall
     ↓
    Nginx
     ↓
    TLS
     ↓
    HTTP
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL

    That chain is the foundation for diagnosing almost every web-hosting problem.

  • CresignSys Learn — Lesson 046

    MySQL Deep Internals — From SQL Query to Disk

    We now go one level deeper than ordinary MySQL administration.

    So far:

    Browser
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL

    Today:

    WordPress
     ↓
    SQL
     ↓
    MySQL
     ↓
    Query processing
     ↓
    InnoDB
     ↓
    RAM
     ↓
    Disk

    The goal is to understand what actually happens inside MySQL when WordPress asks for data.


    1. Start With One Simple Question

    Suppose WordPress asks:

    SELECT *
    FROM wp_posts
    WHERE ID = 100;

    What happens?

    It does not simply mean:

    MySQL → open file → find row

    There are several internal stages.


    2. The Basic Pipeline

    Conceptually:

    SQL Query
       ↓
    Connection
       ↓
    Parser
       ↓
    Optimizer
       ↓
    Execution
       ↓
    Storage Engine
       ↓
    InnoDB
       ↓
    Buffer Pool / Disk
       ↓
    Result

    Let’s examine every layer.


    3. Step 1 — Connection

    PHP needs to communicate with MySQL.

    PHP Worker
         ↓
    MySQL connection
         ↓
    MySQL Server

    The connection contains information such as:

    username
    password
    database
    host
    port/socket

    4. Step 2 — SQL Arrives

    WordPress sends a query such as:

    SELECT ID, post_title
    FROM wp_posts
    WHERE ID = 100;

    MySQL receives this query.


    5. Step 3 — Parser

    MySQL first parses the SQL.

    It identifies:

    SELECT
    columns
    FROM
    table
    WHERE
    condition

    Conceptually:

    SQL text
       ↓
    Parser
       ↓
    understood query structure

    6. Syntax Error

    If the SQL is invalid:

    SELEC *
    FROM wp_posts;

    MySQL can reject it because:

    SELEC

    is not valid SQL syntax.

    The parser is one of the layers involved in identifying this.


    7. Step 4 — Query Optimizer

    Suppose the query is valid.

    MySQL now needs to determine an efficient way to execute it.

    This is the job of the:

    Query Optimizer


    8. Why Do We Need an Optimizer?

    Suppose a table contains:

    1,000,000 rows

    MySQL has multiple possible strategies.

    Strategy A

    Read every row:

    row 1
    row 2
    row 3
    ...
    row 1,000,000

    Strategy B

    Use an index:

    ID = 100
     ↓
    index
     ↓
    row 100

    The second can be dramatically faster.


    9. Query Plan

    The optimizer creates a plan for executing the query.

    You can inspect a query plan with:

    EXPLAIN

    Example:

    EXPLAIN
    SELECT *
    FROM wp_posts
    WHERE ID = 100;

    10. EXPLAIN

    EXPLAIN is one of the most important tools for database performance analysis.

    It can show information such as:

    table
    type
    possible_keys
    key
    rows
    filtered
    Extra

    The exact output depends on MySQL version and query.


    11. The Key Question

    When examining:

    EXPLAIN SELECT ...

    one important question is:

    Is MySQL using an appropriate index?


    12. What Is an Index?

    Imagine a library with:

    1,000,000 books

    and you want:

    Book ID 783421

    Without an index, you might search through many books.

    With an index:

    783421
      ↓
    location
      ↓
    book

    A database index provides a similar lookup structure.


    13. Index Example

    Suppose:

    wp_posts

    has:

    ID
    post_title
    post_content
    post_date

    and ID is indexed.

    Then:

    WHERE ID = 100

    can efficiently locate the record.


    14. Primary Key

    A primary key is normally indexed.

    For example:

    wp_posts
       ↓
    ID

    The ID uniquely identifies a post row.


    15. Why Indexes Matter

    Suppose:

    1,000 rows

    A full scan might be acceptable.

    But:

    10 million rows

    makes inefficient scanning much more expensive.

    Indexes can reduce the amount of data MySQL needs to inspect.


    16. But Indexes Have a Cost

    Indexes consume:

    Disk
    RAM
    CPU
    write/update resources

    When a row changes, relevant indexes may also need updating.

    Therefore:

    An index is an optimization, not free storage.


    17. WordPress and Indexes

    WordPress tables contain indexes designed around common access patterns.

    You can inspect them using:

    SHOW INDEX FROM wp_posts;

    This shows index information for the table.


    18. Storage Engine

    After the optimizer determines a plan, MySQL relies on a storage engine.

    For modern WordPress installations, the important engine is:

    InnoDB


    19. InnoDB

    InnoDB is the storage engine responsible for storing and retrieving table data and indexes.

    Conceptually:

    MySQL
     ↓
    InnoDB
     ↓
    tables + indexes

    20. Why InnoDB Matters

    InnoDB provides major database capabilities including:

    Transactions
    Crash recovery
    Row-level locking
    Indexes
    Buffer pool
    Redo logging
    Undo information

    These are fundamental to reliable database operation.


    21. InnoDB Does Not Read Every Byte From Disk

    This is one of the most important performance concepts.

    MySQL tries to keep frequently needed data in RAM.

    The main mechanism is:

    InnoDB Buffer Pool


    22. Buffer Pool

    Think of the buffer pool as:

    RAM
     ↓
    frequently used database pages

    Instead of repeatedly reading from disk:

    Disk → RAM → query

    MySQL can often use:

    RAM → query

    which is much faster.


    23. Simple Analogy

    Imagine your desk and a warehouse.

    Desk
    =
    RAM
    Warehouse
    =
    Disk

    If you repeatedly need the same document, you keep it on your desk.

    You don’t walk to the warehouse every time.

    The buffer pool works somewhat like the desk.


    24. Buffer Pool Flow

    Conceptually:

    SQL Query
       ↓
    InnoDB
       ↓
    Buffer Pool
       │
       ├── Data already in RAM?
       │       ↓
       │      YES
       │       ↓
       │    use it
       │
       └── NO
               ↓
             Disk
               ↓
            load page
               ↓
           Buffer Pool

    25. Cache Hit

    If the required page is already in memory:

    Buffer Pool
     ↓
    FOUND

    This is much faster than disk access.


    26. Cache Miss

    If it isn’t:

    Buffer Pool
     ↓
    NOT FOUND
     ↓
    Disk read
     ↓
    Memory

    This introduces additional I/O latency.


    27. Why RAM Matters

    For a WordPress server:

    More useful RAM
     ↓
    larger useful caches
     ↓
    fewer disk reads
     ↓
    potentially better performance

    But RAM isn’t the only performance factor.

    CPU, storage, queries, indexes, PHP-FPM, and application behavior all matter.


    28. SSD vs HDD

    Storage speed also matters.

    Traditional HDD:

    mechanical movement
     ↓
    slower random access

    SSD/NVMe:

    electronic flash storage
     ↓
    much faster random access

    Modern VPS infrastructure commonly uses SSD/NVMe-backed storage, but the exact storage architecture depends on the provider.


    29. Database Pages

    InnoDB doesn’t think primarily in terms of:

    one row at a time

    It organizes data into fixed-size pages.

    A common InnoDB page size is:

    16 KB

    unless configured differently.


    30. Why Pages?

    Suppose you need one row.

    The database can load the relevant page containing that row into memory.

    Conceptually:

    Disk
    │
    ├── Page
    ├── Page
    ├── Page
    └── Page

    The buffer pool stores these pages.


    31. Page Flow

    Disk
     ↓
    InnoDB page
     ↓
    Buffer pool
     ↓
    SQL operation

    When a page changes:

    Application
     ↓
    modify page in memory
     ↓
    eventually persist changes

    The details involve InnoDB’s logging and flushing mechanisms.


    32. Dirty Page

    Suppose a page is loaded into memory.

    WordPress changes some data.

    The in-memory page is modified.

    It is now called a:

    Dirty page

    Conceptually:

    Clean page
     ↓
    modify
     ↓
    Dirty page

    33. Why Not Immediately Write Everything to Disk?

    Constantly writing every tiny modification directly to disk could be inefficient.

    Instead, InnoDB uses buffering and logging mechanisms to balance performance and durability.


    34. Redo Log

    One critical component is the:

    Redo Log

    Its purpose is related to durability and crash recovery.

    Conceptually:

    Change
     ↓
    Redo information
     ↓
    persistent log

    If a crash occurs, InnoDB can use redo information during recovery.


    35. Simple Example

    Suppose:

    Post title:
    Hello

    changes to:

    Hello World

    InnoDB updates internal structures and records appropriate redo information.

    If the system crashes before every modified data page reaches its final disk location, recovery can use the redo log to help restore committed changes.


    36. Undo Information

    InnoDB also maintains undo information.

    Undo supports operations such as:

    rollback
    consistent reads
    transaction processing

    Conceptually:

    Current data
    +
    history/undo information

    37. Redo vs Undo

    Remember:

    REDO
    =
    help recover/reapply committed changes after failure
    
    UNDO
    =
    help roll back changes / provide older versions for transactional consistency

    The exact internal mechanics are more sophisticated, but this mental model is useful.


    38. Transaction Example

    Suppose an application performs:

    Operation 1
    Operation 2
    Operation 3

    inside a transaction.

    Then:

    COMMIT

    means the transaction is finalized.

    If it needs to be cancelled:

    ROLLBACK

    can reverse its changes where transaction semantics permit.


    39. WordPress Doesn’t Usually Mean One SQL Query

    A WordPress page request can trigger many database queries.

    For example:

    Request
     ↓
    WordPress bootstrap
     ↓
    settings queries
     ↓
    plugin queries
     ↓
    theme queries
     ↓
    post query
     ↓
    metadata queries
     ↓
    taxonomy queries
     ↓
    ...

    Therefore page performance can depend heavily on database behavior.


    40. Plugin Effect

    Suppose you install:

    Plugin A
    Plugin B
    Plugin C
    Plugin D

    A page request might cause more database work.

    Conceptually:

    No plugins
     ↓
    fewer queries
    
    Many plugins
     ↓
    potentially more queries

    But the number of queries alone isn’t enough to judge performance; query complexity and execution time matter too.


    41. Query Count vs Query Time

    Imagine:

    100 queries × 1 ms
    =
    100 ms

    versus:

    5 queries × 500 ms
    =
    2500 ms

    The second can be much slower despite fewer queries.


    42. Slow Query

    A slow query might be caused by:

    Missing index
    Poor query design
    Large dataset
    Bad join strategy
    Heavy sorting
    Large result set
    Resource contention

    43. EXPLAIN

    Suppose:

    SELECT *
    FROM wp_posts
    WHERE post_status = 'publish';

    You can examine:

    EXPLAIN
    SELECT *
    FROM wp_posts
    WHERE post_status = 'publish';

    The plan can help determine whether MySQL scans too much data.


    44. Full Table Scan

    A full table scan means MySQL examines a large portion or all of the table.

    Conceptually:

    wp_posts
     ↓
    row 1
    row 2
    row 3
    ...
    row 1,000,000

    This isn’t always bad.

    For some queries, scanning is the most efficient strategy.


    45. Don’t Fear “ALL” Automatically

    When reading EXPLAIN, seeing:

    type = ALL

    often indicates a full scan.

    But whether it is actually a problem depends on:

    table size
    query purpose
    rows examined
    result size
    alternative indexes

    A full scan of 10 rows isn’t a crisis.

    A full scan of 100 million rows may be very different.


    46. rows

    The rows estimate in EXPLAIN gives an indication of how many rows MySQL expects to examine.

    Lower isn’t automatically better in every circumstance, but excessive row examination is often a performance warning.


    47. Index Selectivity

    An index is especially useful when it can narrow the search significantly.

    Imagine:

    1,000,000 rows

    and an indexed field identifies only:

    1 row

    Very selective.

    But if an indexed field has only:

    2 possible values

    such as:

    yes/no

    it may be less useful depending on the query and data distribution.


    48. Composite Index

    An index can contain multiple columns.

    Example:

    INDEX (A, B)

    This is a:

    Composite index

    The order matters.

    (A, B)

    is not equivalent to:

    (B, A)

    for all query patterns.


    49. Why Index Order Matters

    Suppose:

    INDEX (country, city)

    This is especially useful for queries that start with:

    country

    and then potentially use:

    city

    The exact optimizer behavior depends on the query and statistics.


    50. Don’t Add Random Indexes

    A common beginner mistake is:

    “The database is slow, so I’ll add indexes everywhere.”

    That can make writes more expensive and increase storage usage.

    Proper database optimization starts with:

    measure
     ↓
    identify slow query
     ↓
    EXPLAIN
     ↓
    understand access pattern
     ↓
    optimize
     ↓
    measure again

    51. MySQL RAM

    MySQL uses RAM for several purposes:

    InnoDB buffer pool
    connections
    sort buffers
    temporary structures
    internal caches
    other server memory

    Therefore:

    MySQL RAM usage

    is more than simply:

    buffer pool

    52. Buffer Pool Sizing

    On a dedicated database server, the InnoDB buffer pool can often occupy a large fraction of available memory.

    But your server is not a dedicated MySQL server.

    You also run:

    Nginx
    PHP-FPM
    WordPress
    OS
    other services

    Therefore you cannot simply allocate almost all RAM to MySQL.


    53. Shared VPS

    Your server might look like:

    RAM
    │
    ├── Linux
    ├── Nginx
    ├── PHP-FPM
    ├── MySQL
    ├── SSH
    ├── monitoring
    └── other services

    So resource planning must consider the entire stack.


    54. PHP-FPM vs MySQL Memory

    Suppose:

    PHP-FPM
     ↓
    many workers
     ↓
    high RAM usage

    At the same time:

    MySQL
     ↓
    large buffer pool
     ↓
    high RAM usage

    Together they can exhaust the server.


    55. Swap

    Linux may use swap when memory pressure occurs.

    Conceptually:

    RAM
     ↓
    memory pressure
     ↓
    swap
     ↓
    disk

    Swap is much slower than RAM.

    It can help prevent immediate process termination in some situations, but heavy swapping can severely hurt performance.


    56. OOM Killer

    If the Linux system runs critically short of memory, the kernel may invoke the:

    Out-Of-Memory Killer

    Conceptually:

    RAM exhausted
     ↓
    kernel attempts recovery
     ↓
    process may be killed

    This is why poor PHP-FPM/MySQL memory planning can cause apparently random service failures.


    57. Check Memory

    On Ubuntu:

    free -h

    This gives a quick overview.

    You can also use:

    htop

    if installed.


    58. Check Disk

    df -h

    Remember:

    RAM
    ≠
    Disk

    They are completely different resources.


    59. Check MySQL Processes

    ps aux | grep mysqld

    or:

    ps aux | grep mariadbd

    depending on the database software.


    60. MySQL Status

    Inside MySQL:

    SHOW STATUS;

    There are many metrics.

    You can also query specific status variables.


    61. Connection Count

    A useful metric:

    SHOW STATUS LIKE 'Threads_connected';

    This tells you the current number of connected client threads.


    62. Maximum Connections

    You can inspect:

    SHOW VARIABLES LIKE 'max_connections';

    This is a limit on concurrent client connections.

    Again, setting it extremely high isn’t automatically good.

    Each connection can consume resources.


    63. Too Many Connections

    If MySQL reaches its connection limit:

    PHP-FPM
     ↓
    new connection
     ↓
    MySQL
     ↓
    too many connections
     ↓
    failure

    WordPress may then report database connection errors.


    64. Classic WordPress Error

    A famous WordPress message is:

    Error establishing a database connection.

    Possible causes include:

    MySQL stopped
    Wrong database credentials
    Wrong DB host
    Network/socket problem
    Too many connections
    Database overload
    Corruption
    Resource exhaustion

    65. Diagnostic Sequence

    If WordPress reports a database connection error:

    1. Is MySQL running?
    2. Is the database present?
    3. Does the database user exist?
    4. Are credentials correct?
    5. Can the user access the database?
    6. Is MySQL listening?
    7. Is the socket available?
    8. Is the server overloaded?
    9. Are connections exhausted?

    66. Check MySQL

    sudo systemctl status mysql

    Then:

    sudo journalctl -u mysql -n 100

    67. Test Database Login

    If appropriate:

    mysql -u wordpress_user -p wordpress_db

    You’ll be prompted for the password.

    Do not place database passwords directly into shell history unnecessarily.


    68. Check Database Exists

    Inside MySQL:

    SHOW DATABASES;

    Then:

    USE wordpress_db;

    69. Check Tables

    SHOW TABLES;

    If you see:

    wp_posts
    wp_users
    wp_options
    ...

    the WordPress database is present.


    70. Check WordPress Options

    A useful diagnostic:

    SELECT option_name, option_value
    FROM wp_options
    WHERE option_name IN ('siteurl', 'home');

    This helps confirm important URL configuration values.


    71. Why URL Configuration Matters

    Suppose the site was originally:

    https://oldsite.com

    and you migrate it to:

    https://newsite.com

    but database values still reference:

    oldsite.com

    you can experience:

    redirect problems
    incorrect asset URLs
    login problems
    mixed-content issues

    Migration therefore involves both:

    files
    +
    database

    72. Database Backup

    For WordPress hosting, one of the most important operational principles is:

    A website backup must include both filesystem data and database data.

    Conceptually:

    Backup
    │
    ├── Website files
    │
    └── MySQL database

    73. Why Copying public/ Is Not Enough

    Suppose you copy:

    /storage/websites/example.com/public/

    You have the PHP code and uploads.

    But you don’t necessarily have:

    posts
    users
    settings
    menus
    plugin configuration

    Those are in the database.


    74. Database Restore

    A logical backup might look like:

    wordpress.sql

    Restoration conceptually:

    SQL dump
     ↓
    MySQL
     ↓
    database
     ↓
    WordPress

    A proper disaster-recovery plan should test this process periodically.


    75. Database and Hosting Automation

    Your hosting platform can eventually automate:

    Create website
     ↓
    Create database
     ↓
    Create database user
     ↓
    Grant permissions
     ↓
    Generate wp-config.php
     ↓
    Install WordPress

    This is a major part of a hosting control panel.


    76. Your Hosting Platform Architecture

    You are gradually building toward:

    CresignSys Hosting Platform
    │
    ├── Domain management
    ├── DNS
    ├── Website directories
    ├── Nginx
    ├── SSL
    ├── PHP-FPM
    ├── PHP versions
    ├── MySQL
    ├── Database users
    ├── WordPress
    ├── Backups
    ├── Logs
    └── Monitoring

    Each of these is now becoming understandable as an individual layer.


    77. The Complete Internal Path

    Let’s trace one WordPress database request extremely deeply.

    Browser
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    PHP worker
     ↓
    WordPress
     ↓
    SQL query
     ↓
    MySQL connection
     ↓
    SQL parser
     ↓
    Query optimizer
     ↓
    Execution plan
     ↓
    InnoDB
     ↓
    Index
     ↓
    Buffer pool
     ↓
    Data page
     ↓
    RAM

    If the required page isn’t in memory:

    Buffer Pool
     ↓
    Disk I/O
     ↓
    Storage
     ↓
    page loaded
     ↓
    RAM
     ↓
    InnoDB
     ↓
    WordPress

    78. Now Think About Performance

    A page can become slow at many different points:

    DNS
     ↓
    Network
     ↓
    TLS
     ↓
    Nginx
     ↓
    PHP-FPM queue
     ↓
    PHP execution
     ↓
    WordPress plugin
     ↓
    MySQL query
     ↓
    Disk I/O

    Therefore:

    “The website is slow” is not a diagnosis.

    It is only a symptom.


    79. Performance Diagnosis

    The correct approach is:

    Measure
       ↓
    Find slow layer
       ↓
    Measure that layer
       ↓
    Find bottleneck
       ↓
    Fix bottleneck
       ↓
    Measure again

    This principle will become extremely important as you manage more websites.


    80. Four Major Resources

    For your VPS, constantly think about:

    CPU
    RAM
    Disk I/O
    Network

    A fifth practical resource is:

    Database/application capacity

    although it ultimately consumes the underlying resources.


    81. CPU Bottleneck

    Could look like:

    PHP
     ↓
    CPU 100%

    Possible causes:

    expensive plugin
    heavy PHP computation
    many simultaneous requests
    bad application code
    bot traffic

    82. RAM Bottleneck

    Could look like:

    RAM
     ↓
    nearly exhausted
     ↓
    swap/OOM

    Possible causes:

    too many PHP workers
    large MySQL memory allocation
    memory-heavy plugins
    many concurrent requests

    83. Disk Bottleneck

    Could look like:

    Disk I/O
     ↓
    high latency

    Possible causes:

    database writes
    backups
    logs
    cache operations
    large file operations
    swap

    84. Network Bottleneck

    Could occur when:

    large downloads/uploads
    high traffic
    many connections

    consume network capacity.


    85. Database Bottleneck

    Could be:

    MySQL
     ↓
    slow queries
     ↓
    PHP waits
     ↓
    Nginx waits
     ↓
    Browser waits

    This is why understanding MySQL internals matters to web hosting.


    86. One More Important Concept: Concurrency

    Suppose:

    1 visitor

    requests a page.

    Easy.

    Now:

    100 visitors

    arrive simultaneously.

    The architecture becomes:

    100 HTTP requests
            ↓
          Nginx
            ↓
    PHP-FPM workers
            ↓
    WordPress
            ↓
    MySQL connections/queries

    Every layer must handle concurrency.


    87. PHP-FPM Queue

    If all PHP workers are busy:

    Request
     ↓
    PHP-FPM
     ↓
    no worker available
     ↓
    wait

    This increases response time.


    88. MySQL Queue/Contention

    Similarly, if MySQL is overloaded:

    PHP workers
     ↓
    database requests
     ↓
    MySQL contention
     ↓
    queries take longer

    So increasing PHP-FPM workers can sometimes make an overloaded MySQL server even busier.


    89. This Is Why Tuning Must Be Holistic

    Don’t think:

    Website slow
     ↓
    increase PHP workers

    Instead:

    Website slow
     ↓
    measure
     ↓
    PHP?
    MySQL?
    Disk?
    CPU?
    Network?
    Application?

    Then make the appropriate change.


    90. MySQL’s Deepest Simplified Model

    Remember:

    SQL
     ↓
    Parser
     ↓
    Optimizer
     ↓
    Execution
     ↓
    InnoDB
     ↓
    Index/Data
     ↓
    Buffer Pool
     ↓
    Disk when needed

    And for changes:

    Write
     ↓
    memory/data structures
     ↓
    redo logging
     ↓
    eventual page flushing
     ↓
    persistent storage

    This is a simplified conceptual model, not a complete description of every internal operation.


    91. What You Should Know Now

    You have progressed from:

    "WordPress is a website"

    to:

    Browser
     ↓
    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP
     ↓
    Nginx
     ↓
    FastCGI
     ↓
    PHP-FPM
     ↓
    PHP
     ↓
    WordPress
     ↓
    SQL
     ↓
    MySQL
     ↓
    InnoDB
     ↓
    Buffer Pool
     ↓
    Disk

    That is a substantial part of the foundation of modern PHP hosting.


    Lesson 046 Summary

    The key concepts are:

    Parser
    =
    understands SQL syntax
    
    Optimizer
    =
    chooses an execution strategy
    
    EXPLAIN
    =
    shows query execution plan
    
    Index
    =
    helps locate data efficiently
    
    InnoDB
    =
    major MySQL storage engine
    
    Buffer Pool
    =
    RAM area used to cache InnoDB data/index pages
    
    Dirty Page
    =
    modified in-memory page not yet fully persisted
    
    Redo Log
    =
    supports durability/recovery
    
    Undo
    =
    supports rollback and consistent transactional behavior
    
    Transaction
    =
    logical group of database operations

    The most important mental model:

    WordPress
       ↓
    SQL
       ↓
    MySQL
       ↓
    Optimizer
       ↓
    InnoDB
       ↓
    Buffer Pool
       ↓
    Disk

    Next Lesson — 047

    Linux Networking From Zero — What Actually Happens Between Your VPS and the Internet

    We will go below Nginx and learn:

    Network interface
    IP address
    MAC address
    Ethernet
    ARP
    Subnet
    Gateway
    Routing table
    TCP
    UDP
    Ports
    Sockets
    NAT
    Firewall
    IPv4
    IPv6

    Then connect it directly to your Oracle Cloud VPS:

    Internet
       ↓
    Public IP
       ↓
    VNIC
       ↓
    Subnet
       ↓
    Route table
       ↓
    Security rules
       ↓
    Ubuntu
       ↓
    Nginx
       ↓
    Website

    This will explain why a domain can resolve correctly but a website can still be unreachable, and how DNS, Oracle Cloud networking, Ubuntu firewall, ports 80/443, Nginx, and the browser all fit together.

  • CresignSys Learn — Lesson 045

    MySQL From the Absolute Basics

    We now go one layer deeper.

    Our current architecture is:

    Browser
       ↓
    DNS
       ↓
    IP
       ↓
    TCP
       ↓
    TLS
       ↓
    HTTP
       ↓
    Nginx
       ↓
    PHP-FPM
       ↓
    WordPress
       ↓
    MySQL

    Today we study:

    MySQL

    This is where WordPress stores most of its structured application data.


    1. What Is Data?

    Before MySQL, understand the simplest concept:

    Data is information represented in a form that a computer can store and process.

    Examples:

    Name:
    Abey
    
    Email:
    example@example.com
    
    Post title:
    My First Website
    
    Price:
    499
    
    Date:
    2026-08-13

    A database organizes this information.


    2. What Is a Database?

    A database is a system for storing and retrieving structured information.

    Think:

    Database
    │
    ├── Users
    ├── Products
    ├── Orders
    ├── Settings
    └── Content

    WordPress needs a database because a website contains much more than static files.


    3. Why Can’t WordPress Just Use Files?

    Some information is stored in files:

    WordPress
    ├── PHP files
    ├── CSS
    ├── JavaScript
    ├── Images
    └── Configuration

    But imagine storing thousands of posts, users, comments, settings, relationships, and metadata entirely as individual files.

    Searching and managing that information would become inefficient and complicated.

    A database provides structured querying.


    4. MySQL

    MySQL is a:

    Relational Database Management System

    Often abbreviated:

    RDBMS

    The important word is:

    Relational

    Data is organized into related tables.


    5. MySQL Is Not WordPress

    Keep these separate:

    MySQL
    =
    database management system
    WordPress
    =
    web application

    Relationship:

    WordPress
       ↓
    MySQL

    WordPress uses MySQL to store and retrieve its data.


    6. MySQL Is Not the Database Itself

    A useful distinction:

    MySQL
    =
    software/database server

    Inside MySQL you can have:

    Databases

    Inside databases:

    Tables

    Inside tables:

    Rows

    Inside rows:

    Columns

    7. Hierarchy

    Memorize:

    MySQL Server
        │
        ├── Database A
        │     ├── Table
        │     ├── Table
        │     └── Table
        │
        └── Database B
              ├── Table
              └── Table

    For WordPress:

    MySQL Server
        ↓
    wordpress_database
        ↓
    WordPress tables

    8. Database

    Suppose your WordPress database is called:

    wordpress_db

    It may contain:

    wordpress_db
    │
    ├── wp_posts
    ├── wp_users
    ├── wp_options
    ├── wp_postmeta
    ├── wp_terms
    └── ...

    The actual prefix may not be wp_.


    9. Table

    A table is a structured collection of related records.

    Imagine:

    wp_users

    Conceptually:

    IDuser_loginuser_email
    1adminadmin@example.com
    2johnjohn@example.com

    Each horizontal record is a:

    Row


    10. Column

    A column represents a particular type of information.

    For example:

    wp_users

    might contain columns such as:

    ID
    user_login
    user_pass
    user_email
    user_registered

    So:

    Column
    =
    one attribute/field of the table

    11. Row

    A row represents one record.

    Example:

    1 | admin | admin@example.com

    This represents one user record.


    12. Cell

    The intersection of:

    row
    +
    column

    is a cell/value.

    For example:

    user_email

    for user ID 1 might contain:

    admin@example.com

    13. SQL

    SQL means:

    Structured Query Language

    It is used to communicate with relational databases.

    For example:

    SELECT * FROM wp_users;

    This means approximately:

    Retrieve all rows from wp_users.


    14. SQL Is a Language

    Think:

    PHP
    =
    programming language
    
    SQL
    =
    database query language

    WordPress PHP code can execute SQL queries against MySQL.


    15. Basic SELECT

    Example:

    SELECT * FROM wp_posts;

    Break it down:

    SELECT
    =
    retrieve data
    
    *
    =
    all selected columns
    
    FROM
    =
    source table
    
    wp_posts
    =
    table

    16. Select Specific Columns

    Instead of:

    SELECT * FROM wp_users;

    you can request:

    SELECT ID, user_login, user_email
    FROM wp_users;

    This retrieves only the specified columns.


    17. WHERE

    Suppose you want user ID 5:

    SELECT *
    FROM wp_users
    WHERE ID = 5;

    Conceptually:

    wp_users
       ↓
    find ID = 5
       ↓
    return matching row

    18. SQL Filtering

    Example:

    SELECT *
    FROM wp_posts
    WHERE post_status = 'publish';

    This asks for published posts.


    19. INSERT

    To add a record:

    INSERT INTO ...

    Conceptually:

    INSERT INTO wp_users (...)
    VALUES (...);

    This creates a new database row.


    20. UPDATE

    To modify existing data:

    UPDATE ...

    Example conceptually:

    UPDATE wp_options
    SET option_value = '...'
    WHERE option_name = '...';

    21. DELETE

    To remove records:

    DELETE FROM ...

    Example:

    DELETE FROM table_name
    WHERE id = 10;

    Be extremely careful with DELETE.


    22. The Most Dangerous SQL Mistake

    Never casually execute:

    DELETE FROM wp_posts;

    without a precise understanding of what you’re doing.

    Even more dangerous:

    DELETE FROM wp_posts;

    without a WHERE clause.

    That can remove every row in the table.


    23. WordPress Database

    A normal WordPress installation creates a collection of tables.

    Common examples:

    wp_posts
    wp_postmeta
    wp_users
    wp_usermeta
    wp_options
    wp_terms
    wp_term_taxonomy
    wp_term_relationships
    wp_comments
    wp_commentmeta

    Plugins can create additional tables.


    24. wp_posts

    Despite the name, this table isn’t only for blog posts.

    It can contain different WordPress content types, including:

    Posts
    Pages
    Custom post types
    Attachments
    Revisions

    The exact rows depend on the site’s content.


    25. post_type

    One important column is:

    post_type

    It distinguishes types of content.

    Examples include:

    post
    page
    attachment
    revision

    Plugins can introduce custom post types.


    26. Example

    Conceptually:

    IDpost_titlepost_typepost_status
    10About Uspagepublish
    11Welcomepostpublish
    12Logoattachmentinherit

    So one table can represent multiple types of WordPress objects.


    27. post_status

    Another important field:

    post_status

    Examples can include:

    publish
    draft
    pending
    private
    trash
    inherit

    WordPress uses these states to determine how content is handled.


    28. wp_postmeta

    WordPress needs additional information about posts.

    That’s where:

    wp_postmeta

    comes in.

    Conceptually:

    wp_posts
       │
       │ post ID
       ▼
    wp_postmeta

    29. Metadata

    Metadata means:

    Additional information associated with another object.

    For a post:

    Post
    │
    ├── title
    ├── content
    ├── status
    └── metadata
          ├── custom field
          ├── layout
          └── plugin data

    30. meta_key and meta_value

    wp_postmeta commonly contains:

    post_id
    meta_key
    meta_value

    Example conceptually:

    post_idmeta_keymeta_value
    10page_templatedefault
    10custom_colorblue

    The actual data depends on themes/plugins.


    31. wp_users

    This table stores user records.

    Common fields include:

    ID
    user_login
    user_pass
    user_nicename
    user_email
    user_url
    user_registered
    display_name

    32. Passwords

    Important:

    WordPress should not store user passwords as plain text.

    The database contains password hashes.

    Conceptually:

    Password
       ↓
    password hashing
       ↓
    stored hash

    33. Hashing vs Encryption

    These are different.

    Encryption

    data
     ↓
    encryption
     ↓
    encrypted data
     ↓
    decryption
     ↓
    original data

    Password hashing

    password
     ↓
    hash
     ↓
    stored result

    You don’t normally “decrypt” a password hash to obtain the original password.


    34. wp_usermeta

    Additional user information is commonly stored in:

    wp_usermeta

    For example:

    user ID
    role/capability metadata
    preferences
    plugin-specific data

    35. User Relationships

    Conceptually:

    wp_users
       │
       │ ID
       ▼
    wp_usermeta

    This is an example of a relational relationship.


    36. wp_options

    One of the most important WordPress tables:

    wp_options

    It stores site-wide configuration/options.

    Examples include:

    siteurl
    home
    blogname
    active_plugins
    stylesheet
    template

    and many plugin/theme settings.


    37. siteurl

    WordPress commonly stores the site’s URL in:

    siteurl

    For example:

    https://templates.cresignsys.com

    38. home

    Another important option is:

    home

    It represents the site’s front-end URL.

    Depending on configuration, home and siteurl can be the same or intentionally different.


    39. Why wp_options Matters

    If WordPress cannot correctly read its options:

    WordPress
     ↓
    configuration problems
     ↓
    website errors

    A corrupted or incorrectly modified wp_options table can affect the entire site.


    40. wp_terms

    WordPress uses taxonomy concepts such as:

    Categories
    Tags
    Custom taxonomies

    The term information is stored through tables such as:

    wp_terms
    wp_term_taxonomy
    wp_term_relationships

    41. Taxonomy

    A taxonomy is a system for grouping/classifying content.

    For example:

    Post
    │
    ├── Category: Technology
    ├── Category: Hosting
    └── Tag: Nginx

    42. wp_term_relationships

    This table connects content to taxonomy terms.

    Conceptually:

    Post
      │
      ▼
    relationship
      │
      ▼
    Term

    This is a database relationship.


    43. Why Multiple Tables?

    You might wonder:

    Why not put everything into one giant table?

    Because relational databases organize information into logical structures.

    Instead of:

    ONE HUGE TABLE

    we have:

    Posts
    Users
    Terms
    Metadata
    Comments
    Options

    with relationships between them.


    44. Database Normalization

    This design principle is related to:

    Normalization

    Normalization attempts to organize data so that unnecessary duplication is reduced and relationships are represented cleanly.

    It has several normal forms, such as:

    1NF
    2NF
    3NF

    WordPress’s schema is application-specific and isn’t a textbook example of perfectly normalized relational design everywhere, but the concepts are still important for understanding relational databases.


    45. Primary Key

    A table often has a:

    Primary Key

    It uniquely identifies a row.

    For wp_posts:

    ID

    is the primary identifier.

    Conceptually:

    wp_posts
    ID
    │
    ├── 1
    ├── 2
    ├── 3
    └── 4

    Each identifies a particular record.


    46. Why Primary Keys Matter

    Suppose:

    post ID = 100

    WordPress can refer to that specific post.

    Other tables can store:

    post_id = 100

    to associate information with it.


    47. Foreign Key Concept

    A column that refers to a record in another table is conceptually a:

    Foreign Key

    For example:

    wp_postmeta.post_id

    refers to:

    wp_posts.ID

    WordPress often manages these relationships at the application level rather than relying exclusively on database-enforced foreign-key constraints.


    48. Index

    A database index helps find data efficiently.

    Think about a book.

    Without an index:

    Search every page

    With an index:

    Go directly toward the relevant location

    Database indexes serve a similar purpose.


    49. Example

    Suppose wp_posts contains:

    1,000,000 rows

    Searching every row repeatedly could be expensive.

    An appropriate index can dramatically improve lookup performance for supported query patterns.


    50. Index Trade-Off

    Indexes aren’t free.

    They consume:

    Disk
    RAM
    Write/update overhead

    Therefore:

    More indexes are not automatically better.


    51. SQL Query Flow

    When WordPress needs data:

    WordPress PHP
       ↓
    SQL query
       ↓
    MySQL
       ↓
    Query parser
       ↓
    Query optimizer
       ↓
    Storage engine
       ↓
    Data
       ↓
    Result
       ↓
    WordPress

    52. MySQL Storage Engine

    MySQL can use storage engines.

    The most common modern choice for WordPress is:

    InnoDB

    It provides features such as:

    Transactions
    Row-level locking
    Crash recovery
    Indexes

    53. Transaction

    A transaction groups database operations into a logical unit.

    Conceptually:

    BEGIN
       operation 1
       operation 2
       operation 3
    COMMIT

    If something goes wrong:

    ROLLBACK

    can undo the transaction’s changes, subject to the database/application behavior.


    54. ACID

    Database transactions are often discussed using:

    ACID

    A = Atomicity
    C = Consistency
    I = Isolation
    D = Durability

    55. Atomicity

    A transaction should be treated as an all-or-nothing unit.

    Conceptually:

    3 operations
     ↓
    all succeed
     ↓
    COMMIT

    or:

    failure
     ↓
    ROLLBACK

    56. Consistency

    The database should move from one valid state to another valid state according to its constraints and rules.


    57. Isolation

    Concurrent transactions should not improperly interfere with each other.

    This becomes important when many WordPress requests access MySQL simultaneously.


    58. Durability

    Once a transaction is committed, the database system is designed to preserve the committed data through normal failures, subject to hardware, configuration, and recovery assumptions.


    59. MySQL Connection

    PHP-FPM workers connect to MySQL.

    Conceptually:

    PHP Worker
        │
        ▼
    MySQL connection
        │
        ▼
    MySQL server

    Multiple PHP workers can create concurrent database activity.


    60. Database User

    WordPress normally uses a dedicated MySQL account.

    For example:

    wordpress_user

    with permissions on:

    wordpress_db

    61. Least Privilege

    Don’t use the MySQL root account for WordPress.

    Better:

    WordPress
     ↓
    wordpress_user
     ↓
    wordpress_db

    The database account should have only the privileges required by the application.


    62. WordPress wp-config.php

    WordPress needs database connection information.

    Conceptually:

    define('DB_NAME', 'wordpress_db');
    define('DB_USER', 'wordpress_user');
    define('DB_PASSWORD', '...');
    define('DB_HOST', 'localhost');

    The exact values depend on your installation.


    63. DB_HOST

    The database server could be:

    localhost

    or:

    127.0.0.1

    or a remote database hostname.

    For many single-server WordPress installations:

    WordPress
     ↓
    same VPS
     ↓
    MySQL

    64. Localhost vs 127.0.0.1

    These can behave differently depending on the client library and configuration.

    For MySQL on Linux, localhost often results in Unix-socket communication, while 127.0.0.1 uses TCP.

    This is a useful detail when diagnosing connection problems.


    65. MySQL Unix Socket

    A local MySQL server may expose a socket such as:

    /run/mysqld/mysqld.sock

    Then:

    PHP
     ↓
    Unix socket
     ↓
    MySQL

    can occur.


    66. MySQL TCP

    Alternatively:

    PHP
     ↓
    127.0.0.1:3306
     ↓
    MySQL

    Port:

    3306

    is the conventional MySQL TCP port.

    It can be configured differently.


    67. Check MySQL Service

    On Ubuntu:

    sudo systemctl status mysql

    You may see:

    Active: active (running)

    68. Check MySQL Version

    mysql --version

    Your server has previously been using MySQL 8.x.

    The exact installed version should be checked before making configuration decisions.


    69. Connect to MySQL

    If you have administrative access:

    sudo mysql

    Depending on your authentication configuration, this may open the MySQL shell.

    You might see:

    mysql>

    70. SHOW DATABASES

    Inside MySQL:

    SHOW DATABASES;

    You may see:

    information_schema
    mysql
    performance_schema
    sys
    wordpress_db

    71. Select a Database

    USE wordpress_db;

    Now subsequent table commands operate against that database unless otherwise specified.


    72. Show Tables

    SHOW TABLES;

    You may see:

    wp_options
    wp_posts
    wp_postmeta
    wp_users
    ...

    73. Inspect Table Structure

    Use:

    DESCRIBE wp_posts;

    or:

    SHOW COLUMNS FROM wp_posts;

    This shows columns and their types.


    74. Example Data Types

    MySQL has data types such as:

    INT
    BIGINT
    VARCHAR
    TEXT
    DATETIME
    DECIMAL
    BOOLEAN-like types
    JSON

    The appropriate type depends on the data.


    75. INT

    Used for integer values.

    Example:

    1
    25
    1000

    76. VARCHAR

    Variable-length text.

    Example:

    VARCHAR(255)

    can store text up to a specified maximum length.


    77. TEXT

    Used for larger text content.

    WordPress post content can be large, so text-oriented columns are important.


    78. DATETIME

    Stores date/time values.

    WordPress has many timestamps such as:

    post_date
    post_modified
    user_registered

    79. WordPress Data Flow

    When you create a new page in WordPress:

    Browser
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    SQL INSERT/UPDATE
     ↓
    MySQL
     ↓
    database

    The page’s information is stored in the database.


    80. What About Images?

    This is important.

    WordPress image data is split between:

    Database
    +
    Filesystem

    The actual image file generally lives under:

    wp-content/uploads/

    while information about the attachment is stored in the database.

    Conceptually:

    Image
    ├── Actual file
    │     ↓
    │  filesystem
    │
    └── Metadata
          ↓
        MySQL

    81. WordPress Is Hybrid Storage

    This is a key concept:

    WordPress
    │
    ├── Code
    │    ↓
    │  filesystem
    │
    ├── Media
    │    ↓
    │  filesystem
    │
    └── Structured application data
         ↓
       MySQL

    82. Plugin Installation

    When you install a plugin:

    Plugin PHP files
     ↓
    filesystem

    But plugin configuration may be stored in:

    wp_options

    Some plugins also create their own tables.

    So one plugin can use both:

    Filesystem
    +
    Database

    83. Theme Installation

    Similarly:

    Theme files
     ↓
    wp-content/themes/

    Theme settings may be stored in:

    wp_options

    or other WordPress metadata structures.


    84. User Creation

    When you create a WordPress user:

    Browser
     ↓
    WordPress
     ↓
    MySQL

    data goes into tables such as:

    wp_users
    wp_usermeta

    85. Creating a Post

    Creating a post involves information such as:

    title
    content
    author
    status
    date
    slug

    and may involve:

    wp_posts
    wp_postmeta
    wp_terms
    wp_term_relationships

    depending on the content and taxonomy.


    86. Database Slowness

    Suppose your website takes 5 seconds to generate a page.

    Possible chain:

    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL
     ↓
    slow query

    So the browser may experience:

    5-second response

    even though Nginx itself is fast.


    87. Database Query Optimization

    One area of performance tuning is:

    SQL query
     ↓
    EXPLAIN
     ↓
    query plan
     ↓
    identify bottleneck

    For example:

    EXPLAIN SELECT ...

    This helps understand how MySQL intends to execute a query.


    88. Slow Queries

    MySQL can record slow queries through its slow-query log.

    Conceptually:

    WordPress
     ↓
    slow SQL
     ↓
    MySQL
     ↓
    slow query log

    This is useful when diagnosing database performance.


    89. Database Size

    Check the database size from MySQL.

    For example:

    SELECT
        table_schema AS database_name,
        ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS size_mb
    FROM information_schema.tables
    WHERE table_schema = 'wordpress_db'
    GROUP BY table_schema;

    This can help identify large databases.


    90. Large WordPress Databases

    A WordPress database can grow because of:

    Posts
    Revisions
    Comments
    Metadata
    Plugin data
    WooCommerce data
    Logs
    Transients
    Analytics

    Plugins are often responsible for significant database growth.


    91. Database Backups

    A WordPress backup is not complete if you only copy:

    public/

    You also need the database.

    Conceptually:

    Complete WordPress backup
    │
    ├── Files
    │
    └── Database

    92. Files Backup

    For example:

    wp-content/
    wp-config.php
    WordPress files

    plus any relevant server configuration.


    93. Database Backup

    A common tool is:

    mysqldump

    For example, conceptually:

    mysqldump -u wordpress_user -p wordpress_db > wordpress.sql

    This creates a logical SQL backup.

    Be careful with credentials and backup file permissions.


    94. Restore

    A SQL dump can be restored into a database.

    Conceptually:

    wordpress.sql
     ↓
    MySQL
     ↓
    database

    A proper restore process should be tested rather than assumed.


    95. Disaster Recovery

    For your hosting platform:

    Website
    │
    ├── Files backup
    ├── Database backup
    ├── Nginx configuration
    ├── SSL configuration/state
    └── DNS information

    A real backup strategy should also include off-server storage and restoration testing.


    96. MySQL Is a Separate Service

    Your VPS may have:

    nginx.service
    php8.x-fpm.service
    mysql.service

    These are separate processes/services.

    Conceptually:

    Ubuntu
    │
    ├── Nginx
    ├── PHP-FPM
    └── MySQL

    97. If MySQL Stops

    The website may still load static files:

    /logo.png
    /style.css

    but dynamic WordPress requests may fail or behave incorrectly because WordPress cannot retrieve its database data.


    98. If PHP-FPM Stops

    Nginx may still serve static files.

    But PHP requests can fail:

    .php
     ↓
    PHP-FPM unavailable
     ↓
    502

    99. If Nginx Stops

    The web server itself becomes unavailable even if:

    PHP-FPM ✓
    MySQL ✓

    This illustrates why services form a chain.


    100. Service Dependency Chain

    Browser
       ↓
    Nginx
       ↓
    PHP-FPM
       ↓
    WordPress
       ↓
    MySQL

    A failure at one layer can affect everything above it.


    101. The Deep Architecture

    We can now draw the complete architecture we’ve learned:

                             INTERNET
                                │
                                ▼
                               DNS
                                │
                                ▼
                             IP/Route
                                │
                                ▼
                           TCP / QUIC
                                │
                                ▼
                               TLS
                                │
                                ▼
                              HTTP
                                │
                                ▼
                              NGINX
                                │
                             FastCGI
                                │
                                ▼
                             PHP-FPM
                                │
                                ▼
                           PHP Worker
                                │
                                ▼
                             WORDPRESS
                             /       \
                            /         \
                           ▼           ▼
                     FILESYSTEM      MySQL
                        │              │
                        ▼              ▼
                   wp-content/     wp_posts
                   plugins/        wp_users
                   themes/         wp_options
                   uploads/       wp_postmeta
                                   wp_terms

    This is now a real hosting architecture rather than just a list of technologies.


    102. The Three Major Storage Areas

    For WordPress, think in three categories:

    1. Application code

    PHP
    CSS
    JS

    stored primarily in the filesystem.

    2. Media

    Images
    Videos
    Documents

    stored primarily in the filesystem.

    3. Structured application data

    Posts
    Users
    Settings
    Metadata
    Relationships

    stored primarily in MySQL.


    103. Most Important MySQL Vocabulary

    Memorize:

    Database
    =
    collection of related tables
    
    Table
    =
    structured collection of records
    
    Row
    =
    one record
    
    Column
    =
    one field/attribute
    
    SQL
    =
    database query language
    
    Primary Key
    =
    unique row identifier
    
    Index
    =
    data structure for efficient lookup
    
    Query
    =
    request to database
    
    Transaction
    =
    group of database operations
    
    MySQL
    =
    relational database management system

    104. WordPress Vocabulary

    Memorize:

    wp_posts
    =
    posts/pages/content
    
    wp_postmeta
    =
    post metadata
    
    wp_users
    =
    users
    
    wp_usermeta
    =
    user metadata
    
    wp_options
    =
    site/application settings
    
    wp_terms
    =
    taxonomy terms
    
    wp_term_relationships
    =
    content ↔ taxonomy relationships

    The prefix may differ from wp_.


    105. The Complete Request Now

    A visitor requests:

    https://templates.cresignsys.com/about/

    The full journey is:

    Browser
     ↓
    DNS
     ↓
    IP
     ↓
    TCP
     ↓
    TLS
     ↓
    HTTP
     ↓
    Nginx
     ↓
    FastCGI
     ↓
    PHP-FPM
     ↓
    PHP
     ↓
    WordPress
     ↓
    SQL
     ↓
    MySQL
     ↓
    wp_posts / wp_options / etc.
     ↓
    result
     ↓
    WordPress
     ↓
    PHP
     ↓
    PHP-FPM
     ↓
    Nginx
     ↓
    TLS
     ↓
    Browser

    106. The Next Layer

    We now understand:

    Internet
    DNS
    IP
    TCP
    TLS
    HTTP
    Nginx
    Linux filesystem
    Linux permissions
    PHP-FPM
    PHP
    WordPress
    MySQL

    The next question is:

    How does MySQL itself store data on the disk?

    That takes us deeper into:

    MySQL
     ↓
    InnoDB
     ↓
    pages
     ↓
    indexes
     ↓
    buffer pool
     ↓
    redo log
     ↓
    undo log
     ↓
    disk

    That is where database theory meets actual server storage.


    Next Lesson — 046

    MySQL Deep Internals — From SQL Query to Disk

    We will trace:

    WordPress
     ↓
    SQL
     ↓
    MySQL
     ↓
    Query Parser
     ↓
    Optimizer
     ↓
    Execution
     ↓
    InnoDB
     ↓
    Buffer Pool
     ↓
    Indexes
     ↓
    Data Pages
     ↓
    Redo Log
     ↓
    Disk

    Then we will connect this to why a WordPress website becomes slow, how database indexes work, why RAM matters, what MySQL cache/buffer memory does, and how to diagnose MySQL performance on your Ubuntu VPS.

  • CresignSys Learn — Lesson 044

    PHP-FPM From the Absolute Basics

    We now have:

    Browser
       ↓
    DNS
       ↓
    IP
       ↓
    TCP
       ↓
    TLS
       ↓
    HTTP
       ↓
    Nginx
       ↓
    ?

    The missing component is:

    PHP-FPM

    This is one of the most important technologies to understand if you want to build and manage WordPress hosting.


    1. First: What Is PHP?

    PHP is a programming language commonly used for server-side web applications.

    WordPress is primarily written in PHP.

    For example:

    <?php
    echo "Hello World";

    A PHP program runs on the server.

    The browser normally does not receive the PHP source code.

    Instead:

    PHP source
       ↓
    PHP interpreter
       ↓
    Generated result
       ↓
    HTML
       ↓
    Browser

    2. PHP Is Server-Side

    Compare:

    HTML

    <h1>Hello</h1>

    The browser receives and interprets the HTML.

    PHP

    <?php
    echo "<h1>Hello</h1>";

    The server executes the PHP first.

    The browser receives the resulting HTML:

    <h1>Hello</h1>

    3. Simple Example

    Suppose the server contains:

    /storage/websites/example.com/public/index.php

    with:

    <?php
    
    $name = "CresignSys";
    
    echo "<h1>Hello $name</h1>";

    The browser requests:

    /

    The server executes PHP.

    The browser receives:

    <h1>Hello CresignSys</h1>

    It does not normally receive:

    $name = "CresignSys";

    4. PHP Interpreter

    Something must actually execute PHP code.

    That component is the PHP interpreter/runtime.

    Conceptually:

    PHP file
       ↓
    PHP runtime
       ↓
    execution
       ↓
    output

    But where does PHP-FPM fit?


    5. What Does FPM Mean?

    FPM means:

    FastCGI Process Manager

    So:

    PHP-FPM
    =
    PHP FastCGI Process Manager

    It manages PHP worker processes that execute PHP applications.


    6. Why Do We Need PHP-FPM?

    Nginx is excellent at serving HTTP traffic.

    But Nginx is not a PHP interpreter.

    Therefore:

    Browser
       ↓
    Nginx
       ↓
    PHP-FPM
       ↓
    PHP

    Nginx handles the web side.

    PHP-FPM manages PHP execution.


    7. Nginx and PHP-FPM Have Different Jobs

    Nginx

    Handles:

    HTTP
    TLS
    routing
    static files
    connections
    headers
    reverse proxying

    PHP-FPM

    Handles:

    PHP workers
    PHP execution
    worker lifecycle
    PHP process management

    WordPress

    Handles:

    pages
    posts
    plugins
    themes
    users
    database queries
    application logic

    8. The Complete Flow

    When somebody visits:

    https://templates.cresignsys.com/about/

    the simplified flow is:

    Browser
       ↓
    TLS
       ↓
    HTTP
       ↓
    Nginx
       ↓
    FastCGI
       ↓
    PHP-FPM
       ↓
    PHP
       ↓
    WordPress
       ↓
    MySQL

    Then the result travels back.


    9. What Is FastCGI?

    FastCGI is a protocol/interface for communicating between a web server and an application process manager.

    Conceptually:

    Nginx
      │
      │ FastCGI
      ▼
    PHP-FPM

    Nginx sends information about the HTTP request.

    PHP-FPM passes it to a PHP worker.


    10. Why Not Just Start PHP for Every Request?

    Imagine:

    Request 1
     ↓
    start PHP
     ↓
    execute
     ↓
    stop PHP
    
    Request 2
     ↓
    start PHP
     ↓
    execute
     ↓
    stop PHP

    That would introduce unnecessary process-start overhead.

    PHP-FPM keeps a managed pool of workers.


    11. Worker Processes

    Think of PHP-FPM as a team of PHP workers.

    PHP-FPM
    │
    ├── Worker 1
    ├── Worker 2
    ├── Worker 3
    ├── Worker 4
    └── Worker 5

    Requests can be assigned to available workers.


    12. Why Multiple Workers?

    Suppose 10 users access WordPress simultaneously.

    If only one PHP worker can execute requests:

    Request 1
    Request 2
    Request 3
    ...

    they may wait behind one another.

    With multiple workers:

    Request 1 → Worker 1
    Request 2 → Worker 2
    Request 3 → Worker 3
    Request 4 → Worker 4

    multiple requests can be processed concurrently.


    13. But More Workers Isn’t Always Better

    This is extremely important.

    More workers consume:

    RAM
    CPU
    database connections
    file descriptors

    Suppose each PHP worker uses significant memory.

    If you configure:

    100 PHP workers

    on a small VPS, you may exhaust RAM.

    Therefore:

    PHP-FPM worker configuration must match the server’s resources and workload.


    14. PHP-FPM Pool

    PHP-FPM organizes workers into:

    Pools

    A pool might look conceptually like:

    Pool: www
    │
    ├── Worker
    ├── Worker
    ├── Worker
    └── Worker

    The pool configuration controls how those workers operate.


    15. Default Pool

    On Ubuntu/Debian systems, a common default pool is:

    www

    Its configuration is often under something like:

    /etc/php/<version>/fpm/pool.d/www.conf

    For example:

    /etc/php/8.3/fpm/pool.d/www.conf

    Your installed PHP version may differ.


    16. Find Your PHP Version

    Run:

    php -v

    You might see:

    PHP 8.x.x

    But remember:

    CLI PHP and PHP-FPM can be configured differently.

    So also inspect:

    systemctl list-units --type=service | grep php

    17. Find PHP-FPM Services

    Try:

    systemctl list-units --type=service | grep fpm

    You may see something like:

    php8.3-fpm.service

    18. Check PHP-FPM Status

    For a specific version:

    sudo systemctl status php8.3-fpm

    Replace 8.3 with your installed version.

    You want something similar to:

    Active: active (running)

    19. PHP-FPM Socket

    Nginx needs somewhere to send FastCGI requests.

    A common configuration is:

    /run/php/php8.3-fpm.sock

    This is a Unix socket.


    20. Check PHP Sockets

    Run:

    ls -la /run/php/

    You may see:

    php8.3-fpm.sock

    or multiple versions:

    php8.1-fpm.sock
    php8.2-fpm.sock
    php8.3-fpm.sock

    21. Nginx Configuration

    You may have something like:

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
    }

    This creates the connection:

    Nginx
      ↓
    Unix socket
      ↓
    PHP-FPM

    22. What Is a Unix Socket?

    A Unix socket is a local communication endpoint.

    Instead of using:

    127.0.0.1:9000

    Nginx can communicate through:

    /run/php/php8.3-fpm.sock

    Both processes are on the same server.


    23. TCP Alternative

    PHP-FPM can also listen on a TCP address.

    Conceptually:

    Nginx
     ↓
    127.0.0.1:9000
     ↓
    PHP-FPM

    This is different from:

    Nginx
     ↓
    Unix socket
     ↓
    PHP-FPM

    Both are valid architectures.


    24. Why Unix Sockets Are Common

    For same-machine communication, Unix sockets can be convenient and efficient.

    They also avoid exposing PHP-FPM on a network port unnecessarily.


    25. PHP-FPM Pool Configuration

    A simplified pool might contain:

    [www]
    
    user = www-data
    group = www-data
    
    listen = /run/php/php8.3-fpm.sock
    
    pm = dynamic
    
    pm.max_children = 10
    pm.start_servers = 2
    pm.min_spare_servers = 2
    pm.max_spare_servers = 5

    This is an educational example, not a recommended production configuration for your particular server.


    26. user

    user = www-data

    means worker processes run under that user.

    This connects directly to our previous lesson.

    PHP-FPM
     ↓
    www-data
     ↓
    Linux permissions

    27. group

    group = www-data

    sets the worker process group.

    Again:

    User
    +
    Group
    +
    Filesystem permissions

    determine what PHP can access.


    28. listen

    Example:

    listen = /run/php/php8.3-fpm.sock

    This tells PHP-FPM where to receive FastCGI connections.

    Nginx must point to the corresponding endpoint.


    29. The Socket Must Match

    If Nginx says:

    fastcgi_pass unix:/run/php/php8.3-fpm.sock;

    but PHP-FPM is listening at:

    /run/php/php8.2-fpm.sock

    the connection will fail.

    This can produce:

    502 Bad Gateway


    30. Classic 502 Problem

    Browser
     ↓
    Nginx
     ↓
    PHP-FPM socket
          X

    Possible reasons:

    PHP-FPM stopped
    Wrong socket
    Wrong PHP version
    Socket permissions
    Pool configuration failure
    PHP-FPM crashed

    31. Check the Socket

    Run:

    ls -la /run/php/

    Then compare it with:

    sudo nginx -T | grep fastcgi_pass

    This is a very useful diagnostic.


    32. Process List

    You can inspect PHP processes:

    ps aux | grep php-fpm

    or:

    ps -ef | grep php-fpm

    You may see:

    root      php-fpm: master process
    www-data  php-fpm: pool www
    www-data  php-fpm: pool www
    www-data  php-fpm: pool www

    33. Master Process

    PHP-FPM usually has a master process.

    Conceptually:

    PHP-FPM
    │
    └── Master
         │
         ├── Worker
         ├── Worker
         ├── Worker
         └── Worker

    The master manages the worker pool.


    34. Worker Process

    Workers perform PHP application work.

    For example:

    HTTP request
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    Worker
     ↓
    WordPress

    35. pm

    PHP-FPM has different process-management strategies.

    Common modes include:

    static
    dynamic
    ondemand

    36. Static

    With:

    pm = static

    PHP-FPM maintains a fixed number of workers.

    Example:

    pm.max_children = 10

    means approximately 10 child workers.


    37. Dynamic

    With:

    pm = dynamic

    PHP-FPM dynamically manages the number of child processes within configured limits.

    It uses settings such as:

    pm.max_children
    pm.start_servers
    pm.min_spare_servers
    pm.max_spare_servers

    38. Ondemand

    With:

    pm = ondemand

    workers can be created when requests arrive and removed after an idle period.

    This can be useful for some low-traffic workloads.


    39. pm.max_children

    This is one of the most important settings.

    Example:

    pm.max_children = 10

    It limits the number of child processes in the pool.

    Conceptually:

    Maximum concurrent PHP workers
    =
    10

    40. Why It Matters

    Suppose:

    RAM = 4 GB

    and PHP workers consume significant memory.

    If you allow:

    100 workers

    the system can run out of memory.

    Possible result:

    RAM exhaustion
     ↓
    swap pressure
     ↓
    slow server
     ↓
    process termination
     ↓
    website failures

    41. PHP-FPM and RAM

    A simplified model:

    PHP worker memory
    ×
    number of workers
    ≈
    PHP memory requirement

    This is only an approximation because real memory usage varies.

    But it gives you the right mental model.


    42. CPU Also Matters

    PHP workers consume CPU.

    Suppose:

    100 requests

    all execute heavy WordPress operations.

    Then:

    PHP
     ↓
    CPU saturation

    can occur.

    So PHP-FPM tuning is not just about RAM.


    43. Database Connections

    PHP workers may also interact with MySQL.

    If you have:

    50 PHP workers

    you can potentially have many database interactions occurring concurrently.

    Therefore:

    PHP-FPM capacity

    must be considered together with:

    MySQL capacity

    44. WordPress Request

    Let’s follow one request.

    Browser:

    GET /about/

    Nginx:

    Request matches location /

    Then:

    try_files
     ↓
    index.php

    Then:

    FastCGI
     ↓
    PHP-FPM

    Then:

    PHP worker
     ↓
    WordPress

    45. WordPress Loads

    WordPress may load:

    wp-config.php
    wp-settings.php
    plugins
    theme
    core files

    Then it initializes the application.


    46. WordPress Queries MySQL

    For example, WordPress may need:

    Site settings
    Posts
    Pages
    Menus
    Users
    Metadata
    Plugin settings

    So:

    PHP
     ↓
    MySQL
     ↓
    results
     ↓
    PHP

    47. PHP Generates HTML

    WordPress eventually produces:

    <html>
    <head>
    ...
    </head>
    <body>
    ...
    </body>
    </html>

    Then:

    PHP worker
     ↓
    PHP-FPM
     ↓
    Nginx
     ↓
    Browser

    48. One Request May Be Expensive

    A request can involve:

    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    20+ plugins
     ↓
    Theme
     ↓
    MySQL
     ↓
    External APIs
     ↓
    HTML

    That is why a “simple webpage” can involve significant server work.


    49. PHP OPcache

    PHP has an important performance feature:

    OPcache

    OPcache stores compiled PHP bytecode in shared memory.

    Without OPcache, PHP may repeatedly parse/compile scripts.

    Conceptually:

    PHP source
     ↓
    compile
     ↓
    bytecode
     ↓
    execute

    With OPcache:

    PHP source
     ↓
    compile once
     ↓
    OPcache
     ↓
    reuse compiled code

    50. Why OPcache Matters for WordPress

    WordPress contains a large number of PHP files.

    Plugins and themes add more.

    OPcache can significantly reduce repeated compilation overhead.


    51. Check OPcache

    Run:

    php -m | grep -i opcache

    You can also inspect:

    php -i | grep -i opcache

    But remember that CLI PHP configuration may differ from FPM.


    52. Check FPM PHP Configuration

    A PHP-FPM process may use a configuration such as:

    /etc/php/8.3/fpm/php.ini

    while CLI PHP may use:

    /etc/php/8.3/cli/php.ini

    Therefore:

    CLI PHP
    ≠
    FPM PHP

    necessarily.


    53. Why This Matters

    You might run:

    php -i

    and conclude:

    PHP has this setting.

    But your website may be running under PHP-FPM with a different configuration.

    For website troubleshooting, inspect the FPM configuration.


    54. php.ini

    PHP configuration controls many runtime behaviors.

    Examples include:

    memory_limit
    max_execution_time
    upload_max_filesize
    post_max_size
    max_input_vars
    date.timezone

    55. memory_limit

    Example:

    memory_limit = 256M

    This limits memory available to a PHP request under normal PHP memory accounting.

    It does not mean:

    Every PHP worker permanently consumes 256 MB.

    Actual memory usage varies.


    56. max_execution_time

    Example:

    max_execution_time = 60

    This controls how long PHP code is allowed to execute under the relevant PHP semantics.

    It is not a universal guarantee that every request will terminate exactly at that time because other layers also have timeouts.


    57. upload_max_filesize

    Example:

    upload_max_filesize = 64M

    This limits the size of an individual uploaded file at the PHP level.


    58. post_max_size

    Example:

    post_max_size = 64M

    This limits the maximum size of POST data PHP will accept.

    It should generally be large enough relative to intended uploads.


    59. Multiple Limits Exist

    An upload can be restricted by several layers:

    Browser
     ↓
    Nginx
     ↓
    PHP-FPM/PHP
     ↓
    WordPress

    For example:

    Nginx client_max_body_size
    PHP upload_max_filesize
    PHP post_max_size
    WordPress/application limits

    The smallest effective limit can become the practical restriction.


    60. Nginx vs PHP-FPM

    This distinction is important:

    Nginx
    =
    receives HTTP request
    PHP-FPM
    =
    runs PHP
    PHP
    =
    language/runtime
    WordPress
    =
    application

    61. PHP-FPM Does Not Equal WordPress

    Think:

    PHP-FPM
       ↓
    can run
       ↓
    any compatible PHP application

    It isn’t specifically a WordPress service.

    It can run:

    WordPress
    Laravel
    Drupal
    Magento
    custom PHP

    and many other PHP applications.


    62. One PHP-FPM Pool Can Serve Multiple Sites

    A basic server might use:

    Nginx
     │
     └── PHP-FPM www pool
          ├── site1
          ├── site2
          └── site3

    This is simple.

    But for stronger isolation, separate pools/users can be used.


    63. Multi-Tenant Hosting

    This becomes important for your hosting platform.

    Imagine:

    CresignSys Hosting
    │
    ├── Customer A
    ├── Customer B
    ├── Customer C
    └── Customer D

    You don’t necessarily want all customers’ PHP applications running with exactly the same privileges.

    A stronger architecture might be:

    Customer A
     ↓
    PHP-FPM pool A
     ↓
    user A
    
    Customer B
     ↓
    PHP-FPM pool B
     ↓
    user B

    64. Why Separate Users Matter

    Suppose:

    Customer A

    has a vulnerable plugin.

    If A’s PHP process runs as:

    customerA

    then Linux permissions can limit access to:

    customerA's files

    instead of:

    all customer websites

    This is an important multi-tenant security principle.


    65. Shared www-data Model

    A simpler model:

    site A → www-data
    site B → www-data
    site C → www-data

    is easier to manage.

    But isolation is weaker.

    A compromise of one application running under the same account can potentially access files writable/readable by that shared account.


    66. Isolated Pool Model

    A more isolated model:

    site A → php-fpm pool A → userA
    site B → php-fpm pool B → userB
    site C → php-fpm pool C → userC

    gives more control.

    It is more complex to configure and manage.


    67. This Is Where Hosting Panels Become Useful

    Hosting panels automate:

    User creation
    Website creation
    PHP-FPM pools
    Nginx configuration
    Permissions
    SSL
    Logs
    Databases
    Backups

    Your CresignSys Hosting Platform is essentially moving toward building these capabilities yourself.


    68. PHP-FPM Logs

    Check service logs with:

    sudo journalctl -u php8.3-fpm

    For recent entries:

    sudo journalctl -u php8.3-fpm -n 100

    Replace the version with yours.


    69. Follow Logs Live

    sudo journalctl -u php8.3-fpm -f

    Then make a website request.

    You can observe whether PHP-FPM reports errors.


    70. Nginx + PHP-FPM Debugging

    If you receive:

    502 Bad Gateway

    use this sequence:

    1. Is Nginx running?
    2. Is PHP-FPM running?
    3. Does the socket exist?
    4. Does Nginx point to the correct socket?
    5. Can Nginx connect to the socket?
    6. Are socket permissions correct?
    7. Does PHP-FPM report errors?

    71. Check Service

    systemctl status php8.3-fpm

    72. Check Socket

    ls -l /run/php/

    73. Check Nginx Configuration

    sudo nginx -T | grep -n fastcgi_pass

    74. Check Nginx Errors

    sudo tail -f /var/log/nginx/error.log

    75. Check PHP-FPM Errors

    sudo journalctl -u php8.3-fpm -f

    76. This Gives a Complete Diagnostic Chain

    Browser
       ↓
    HTTP 502
       ↓
    Nginx
       ↓
    error.log
       ↓
    PHP-FPM
       ↓
    journalctl
       ↓
    socket
       ↓
    Linux permissions

    Instead of randomly changing configuration, you identify the failing layer.


    77. Test PHP Directly

    Create a temporary test file only when needed and remove it afterward:

    <?php
    phpinfo();

    For example:

    /storage/websites/example.com/public/test.php

    Then visit:

    https://example.com/test.php

    This shows the PHP environment used by the website.


    78. Security Warning

    phpinfo() exposes extensive environment information.

    Do not leave it publicly accessible.

    After testing:

    rm /storage/websites/example.com/public/test.php

    79. Better: Temporary Diagnostic Endpoint

    For production environments, prefer safer diagnostics rather than leaving phpinfo() publicly available.

    The principle is:

    diagnostic information
     ↓
    temporary
     ↓
    restricted
     ↓
    removed after use

    80. PHP Version

    Different PHP versions can behave differently.

    For example:

    PHP 8.1
    PHP 8.2
    PHP 8.3
    PHP 8.4

    Applications and plugins may have compatibility requirements.

    Therefore a hosting platform must manage PHP versions carefully.


    81. Multiple PHP Versions

    A server can potentially have:

    PHP 8.1
    PHP 8.2
    PHP 8.3
    PHP 8.4

    with different FPM services:

    php8.1-fpm
    php8.2-fpm
    php8.3-fpm
    php8.4-fpm

    Then different websites can use different versions.


    82. Example

    siteA.com
     ↓
    PHP 8.2 FPM
    
    siteB.com
     ↓
    PHP 8.3 FPM
    
    siteC.com
     ↓
    PHP 8.4 FPM

    Nginx determines which PHP-FPM endpoint each website uses.


    83. Why Hosting Providers Offer PHP Versions

    Customers may have applications that require:

    specific PHP version

    A hosting platform therefore often offers:

    PHP version selector

    This is a significant feature for a commercial hosting system.


    84. PHP Lifecycle

    PHP versions eventually reach:

    Active support
     ↓
    Security support
     ↓
    End of life

    A hosting platform should avoid encouraging unsupported PHP versions unless there is a specific legacy requirement and appropriate risk management.


    85. WordPress Compatibility

    WordPress itself, themes, and plugins can have different compatibility requirements.

    Therefore changing:

    PHP 8.2 → 8.4

    should be tested rather than done blindly on production websites.


    86. PHP-FPM Is a Process Manager

    Remember the full meaning:

    PHP
    =
    language/runtime
    
    FastCGI
    =
    communication protocol/interface
    
    FPM
    =
    process manager

    Together:

    PHP-FPM
    =
    managed PHP execution through FastCGI

    87. Deep Request Architecture

    Now our architecture is:

    Browser
       │
       ▼
    HTTPS
       │
       ▼
    Nginx
       │
       │ FastCGI
       ▼
    PHP-FPM master
       │
       ▼
    PHP worker
       │
       ▼
    WordPress
       │
       ▼
    MySQL

    And the filesystem/security layer:

    PHP worker
       │
       ▼
    Linux user
       │
       ▼
    Linux kernel
       │
       ▼
    Filesystem

    88. The Most Important Concepts

    Memorize these:

    PHP
    =
    server-side programming language/runtime
    
    PHP-FPM
    =
    PHP process manager
    
    FastCGI
    =
    communication mechanism between Nginx and PHP-FPM
    
    Pool
    =
    group of PHP workers
    
    Worker
    =
    process that executes PHP requests
    
    Socket
    =
    communication endpoint
    
    OPcache
    =
    compiled PHP bytecode cache
    
    php.ini
    =
    PHP configuration
    
    pm.max_children
    =
    maximum child workers for a pool

    89. One Complete WordPress Request

    Let’s put everything together.

    User requests:

    https://templates.cresignsys.com/about/

    DNS

    domain
     ↓
    IP

    TCP

    client
     ↓
    server:443

    TLS

    secure channel

    HTTP

    GET /about/
    Host: templates.cresignsys.com

    Nginx

    server_name
     ↓
    location /
     ↓
    try_files

    PHP-FPM

    FastCGI
     ↓
    PHP worker

    WordPress

    load WordPress
     ↓
    plugins
     ↓
    theme
     ↓
    database

    MySQL

    query
     ↓
    result

    PHP

    generate HTML

    Nginx

    send response

    TLS

    encrypt response

    Browser

    decrypt
     ↓
    parse HTML
     ↓
    render page

    90. The Full Hosting Stack

    You can now visualize your server as:

                             INTERNET
                                │
                                ▼
                               DNS
                                │
                                ▼
                             IP/Route
                                │
                                ▼
                            TCP / QUIC
                                │
                                ▼
                               TLS
                                │
                                ▼
                              HTTP
                                │
                                ▼
                              NGINX
                                │
                     ┌──────────┴──────────┐
                     │                     │
                     ▼                     ▼
                 Static files          FastCGI
                                           │
                                           ▼
                                      PHP-FPM
                                           │
                                      ┌────┴────┐
                                      ▼         ▼
                                   Worker 1   Worker 2
                                      │
                                      ▼
                                  WordPress
                                      │
                                      ▼
                                    MySQL
                                      │
                                      ▼
                                  Filesystem
                                      │
                                      ▼
                                 Linux Kernel
                                      │
                             ┌────────┴────────┐
                             ▼                 ▼
                            RAM               Disk

    This is the core architecture of a traditional PHP WordPress hosting environment.


    Lesson 044 Summary

    The most important idea:

    Nginx receives the web request; PHP-FPM provides managed PHP execution; WordPress is the PHP application.

    The relationship is:

    Nginx
      ↓
    FastCGI
      ↓
    PHP-FPM
      ↓
    PHP worker
      ↓
    WordPress
      ↓
    MySQL

    And PHP-FPM’s resources are controlled through:

    workers
    pools
    memory
    CPU
    sockets
    timeouts
    PHP configuration
    OPcache

    For your own hosting platform, this is the layer where website performance, PHP version selection, resource limits, and multi-tenant isolation become major design considerations.


    Next Lesson — 045

    MySQL From the Absolute Basics — How WordPress Stores Everything

    We will start from:

    What is data?
    What is a database?
    What is SQL?
    What is MySQL?
    What is a table?
    What is a row?
    What is a column?
    What is a primary key?
    What is an index?

    Then connect it directly to WordPress:

    Browser
     ↓
    Nginx
     ↓
    PHP-FPM
     ↓
    WordPress
     ↓
    MySQL
     ├── wp_posts
     ├── wp_users
     ├── wp_options
     ├── wp_postmeta
     ├── wp_terms
     └── wp_usermeta

    and trace exactly what happens inside MySQL when you create a WordPress page, user, plugin, menu, or post.