VPS Episode 2
- Atul
- Technology , Web , Free software , The big o community , Vps
- March 16, 2025
Table of Contents
VPS Episode 2
root@atulya:~# systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION >
apache2.service loaded active running The Apache HTTP Server
apparmor.service loaded active exited Load AppArmor profiles
cloud-config.service loaded active exited Apply the settings specified in cloud-config
cloud-final.service loaded active exited Execute cloud user/final scripts
cloud-init-local.service loaded active exited Initial cloud-init job (pre-networking)
cloud-init.service loaded active exited Initial cloud-init job (metadata service cr>
coturn.service loaded active running coTURN STUN/TURN Server
cron.service loaded active running Regular background program processing daemon
dbus.service loaded active running D-Bus System Message Bus
exim4.service loaded active running LSB: exim Mail Transport Agent
getty@tty1.service loaded active running Getty on tty1
kmod-static-nodes.service loaded active exited Create List of Static Device Nodes
mariadb.service loaded active running MariaDB 10.11.11 database server
โ nginx.service loaded failed failed A high performance web server and a reverse>
packagekit.service loaded active running PackageKit Daemon
polkit.service loaded active running Authorization Manager
postgresql.service loaded active exited PostgreSQL RDBMS
postgresql@15-main.service loaded active running PostgreSQL Cluster 15-main
prosody.service loaded active running Prosody XMPP Server
qemu-guest-agent.service loaded active running QEMU Guest Agent
serial-getty@ttyS0.service loaded active running Serial Getty on ttyS0
ssh.service loaded active running OpenBSD Secure Shell server
systemd-binfmt.service loaded active exited Set Up Additional Binary Formats
systemd-growfs@-.service loaded active exited Grow File System on /
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running User Login Management
systemd-modules-load.service loaded active exited Load Kernel Modules
systemd-network-generator.service loaded active exited Generate network units from Kernel command >
systemd-networkd-wait-online.service loaded active exited Wait for Network to be Configured
systemd-networkd.service loaded active running Network Configuration
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-resolved.service loaded active running Network Name Resolution
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-sysusers.service loaded active exited Create System Users
systemd-timesyncd.service loaded active running Network Time Synchronization
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create System Files and Directories
systemd-udev-trigger.service loaded active exited Coldplug All udev Devices
systemd-udevd.service loaded active running Rule-based Manager for Device Events and Fi>
systemd-update-utmp.service loaded active exited Record System Boot/Shutdown in UTMP
systemd-user-sessions.service loaded active exited Permit User Sessions
ufw.service loaded active exited Uncomplicated firewall
unattended-upgrades.service loaded active running Unattended Upgrades Shutdown
user-runtime-dir@0.service loaded active exited User Runtime Directory /run/user/0
user@0.service loaded active running User Manager for UID 0
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
47 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
root@atulya:~#
root@atulya:~# systemctl list-units --type=service
UNIT LOAD ACTIVE SUB DESCRIPTION >
apache2.service loaded active running The Apache HTTP Server
apparmor.service loaded active exited Load AppArmor profiles
cloud-config.service loaded active exited Apply the settings specified in cloud-config
cloud-final.service loaded active exited Execute cloud user/final scripts
cloud-init-local.service loaded active exited Initial cloud-init job (pre-networking)
cloud-init.service loaded active exited Initial cloud-init job (metadata service cr>
coturn.service loaded active running coTURN STUN/TURN Server
cron.service loaded active running Regular background program processing daemon
dbus.service loaded active running D-Bus System Message Bus
exim4.service loaded active running LSB: exim Mail Transport Agent
getty@tty1.service loaded active running Getty on tty1
kmod-static-nodes.service loaded active exited Create List of Static Device Nodes
mariadb.service loaded active running MariaDB 10.11.11 database server
โ nginx.service loaded failed failed A high performance web server and a reverse>
packagekit.service loaded active running PackageKit Daemon
polkit.service loaded active running Authorization Manager
postgresql.service loaded active exited PostgreSQL RDBMS
postgresql@15-main.service loaded active running PostgreSQL Cluster 15-main
prosody.service loaded active running Prosody XMPP Server
qemu-guest-agent.service loaded active running QEMU Guest Agent
serial-getty@ttyS0.service loaded active running Serial Getty on ttyS0
ssh.service loaded active running OpenBSD Secure Shell server
systemd-binfmt.service loaded active exited Set Up Additional Binary Formats
systemd-growfs@-.service loaded active exited Grow File System on /
systemd-journal-flush.service loaded active exited Flush Journal to Persistent Storage
systemd-journald.service loaded active running Journal Service
systemd-logind.service loaded active running User Login Management
systemd-modules-load.service loaded active exited Load Kernel Modules
systemd-network-generator.service loaded active exited Generate network units from Kernel command >
systemd-networkd-wait-online.service loaded active exited Wait for Network to be Configured
systemd-networkd.service loaded active running Network Configuration
systemd-random-seed.service loaded active exited Load/Save Random Seed
systemd-remount-fs.service loaded active exited Remount Root and Kernel File Systems
systemd-resolved.service loaded active running Network Name Resolution
systemd-sysctl.service loaded active exited Apply Kernel Variables
systemd-sysusers.service loaded active exited Create System Users
systemd-timesyncd.service loaded active running Network Time Synchronization
systemd-tmpfiles-setup-dev.service loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service loaded active exited Create System Files and Directories
systemd-udev-trigger.service loaded active exited Coldplug All udev Devices
systemd-udevd.service loaded active running Rule-based Manager for Device Events and Fi>
systemd-update-utmp.service loaded active exited Record System Boot/Shutdown in UTMP
systemd-user-sessions.service loaded active exited Permit User Sessions
ufw.service loaded active exited Uncomplicated firewall
unattended-upgrades.service loaded active running Unattended Upgrades Shutdown
user-runtime-dir@0.service loaded active exited User Runtime Directory /run/user/0
user@0.service loaded active running User Manager for UID 0
LOAD = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB = The low-level unit activation state, values depend on unit type.
47 loaded units listed. Pass --all to see loaded but inactive units, too.
To show all installed unit files use 'systemctl list-unit-files'.
root@atulya:~#
Your VPS Service Architecture: A Beautiful Layer-by-Layer Journey ๐๏ธ
Welcome to the fascinating world of your VPS! Let’s explore how all these services work together like a perfectly orchestrated symphony. Think of your server as a digital city with different districts, each serving a unique purpose! ๐๏ธ
๐ The Current State of Your Digital Kingdom
First, let’s address the elephant in the room - you have a failed nginx service ๐จ while Apache is running perfectly. This is actually quite common when both web servers try to use port 80/443. We’ll dive into this later!
๐๏ธ LAYER 1: The Foundation (System Core)
These are the bedrock services that make everything else possible:
๐ง Systemd Services (The Operating System Brain)
systemd-journald.service - Your system's memory keeper ๐
systemd-logind.service - User session manager ๐ฅ
systemd-networkd.service - Network configuration wizard ๐
systemd-resolved.service - DNS name resolver ๐
systemd-timesyncd.service - Time synchronization keeper โฐ
What they do: These are like the city’s infrastructure - power grid, water system, and transportation network. Without them, nothing else functions!
๐ง Device & Hardware Management
systemd-udevd.service - Hardware device detective ๐ต๏ธ
qemu-guest-agent.service - VM communication bridge ๐
The Magic: Your VPS runs as a virtual machine, and the QEMU guest agent lets it communicate with the host system. It’s like having a translator between your virtual world and the physical server!
๐๏ธ LAYER 2: Security & Access Control
Your digital bouncer and security team:
๐ก๏ธ Security Framework
apparmor.service - Application security enforcer ๐ก๏ธ
polkit.service - Permission authorization manager ๐๏ธ
ufw.service - Uncomplicated Firewall ๐ฅ
๐ช Access & Authentication
ssh.service - Secure remote access gateway ๐
getty@tty1.service - Local console login ๐ป
serial-getty@ttyS0.service - Serial console access ๐บ
Beautiful Architecture: SSH is your secure tunnel into the server (port 22), while getty services provide console access. It’s like having both a secure front door and emergency exits!
๐๏ธ LAYER 3: Data & Database Layer
The treasure vaults of your digital kingdom:
๐พ Database Powerhouses
mariadb.service - MySQL-compatible database ๐๏ธ
postgresql.service - PostgreSQL database cluster manager ๐
postgresql@15-main.service - Specific PostgreSQL instance (v15) ๐๏ธ
The Beauty: You’re running both MariaDB AND PostgreSQL! This gives you incredible flexibility:
- MariaDB: Perfect for web applications, WordPress, etc.
- PostgreSQL: Excellent for complex applications requiring advanced features
๐๏ธ LAYER 4: Web & Communication Layer
The face of your server to the outside world:
๐ Web Server Battle Royale
apache2.service - The reliable web server veteran โ
RUNNING
nginx.service - The high-performance newcomer โ FAILED
The Drama: You have both Apache and Nginx installed! Here’s what’s happening:
- Apache is currently serving on port 80/443 (running perfectly) ๐ญ
- Nginx failed to start because Apache already claimed those ports ๐ช
- This is like having two restaurants trying to use the same address!
๐ง Communication Services
exim4.service - Mail transport agent ๐ฎ
prosody.service - XMPP chat server ๐ฌ
coturn.service - STUN/TURN server for real-time communication ๐
The Communication Stack:
- Exim4: Handles sending/receiving emails
- Prosody: Powers instant messaging (like your own Discord!)
- coTURN: Helps with video calls and peer-to-peer connections
๐๏ธ LAYER 5: Automation & Maintenance
The invisible workforce keeping everything running:
๐ค Background Workers
cron.service - Task scheduler extraordinaire โฐ
packagekit.service - Software package manager ๐ฆ
unattended-upgrades.service - Automatic security updater ๐
โ๏ธ Cloud Integration
cloud-init-local.service - Pre-network cloud setup ๐ค๏ธ
cloud-init.service - Cloud metadata processor โ๏ธ
cloud-config.service - Cloud configuration applier โ๏ธ
cloud-final.service - Final cloud setup tasks โ
Cloud Magic: These services make your VPS “cloud-aware” - they automatically configure networking, SSH keys, and initial setup based on your cloud provider’s metadata!
๐๏ธ LAYER 6: User & Session Management
Managing who’s who and what they can do:
๐ค User Services
user-runtime-dir@0.service - Root user runtime directory ๐
user@0.service - Root user session manager ๐
systemd-user-sessions.service - User session coordinator ๐ญ
๐ฏ The Beautiful Architecture in Action
Here’s how a typical web request flows through your system:
1. ๐ Internet Request arrives
2. ๐ก๏ธ UFW Firewall checks if allowed
3. ๐ systemd-networkd handles network routing
4. ๐ systemd-resolved resolves domain names
5. ๐ญ Apache receives and processes the request
6. ๐๏ธ Apache might query MariaDB for data
7. ๐ systemd-journald logs everything
8. ๐ฎ If needed, Exim4 sends notification emails
๐จ The Nginx Mystery Solved
Your nginx service failed because:
- Port Conflict: Both Apache and Nginx want ports 80 and 443
- Apache Started First: It claimed the ports during boot
- Nginx Couldn’t Bind: Failed with “Address already in use”
๐ง Solutions:
Option 1: Choose One Winner
# If you prefer Nginx (faster, lighter)
sudo systemctl stop apache2
sudo systemctl disable apache2
sudo systemctl start nginx
sudo systemctl enable nginx
# If you prefer Apache (more features, easier config)
sudo systemctl stop nginx
sudo systemctl disable nginx
# Keep Apache running (it's already working!)
Option 2: Use Both (Advanced)
# Configure Nginx as reverse proxy (port 80/443)
# Configure Apache on different ports (8080/8443)
# Nginx forwards requests to Apache when needed
๐ Your Server’s Superpowers
With this setup, your VPS can handle:
- ๐ Multiple websites (Apache/Nginx)
- ๐พ Complex databases (MariaDB + PostgreSQL)
- ๐ง Email services (Exim4)
- ๐ฌ Chat applications (Prosody XMPP)
- ๐ Video/voice calls (coTURN)
- ๐ Automatic maintenance (unattended-upgrades)
- ๐ก๏ธ Enterprise security (AppArmor + UFW)
- โ๏ธ Cloud-native features (cloud-init)
๐ฏ Pro Tips for Your VPS
๐ Health Monitoring
# Check what's using your resources
systemd-cgtop
# Monitor your databases
sudo systemctl status mariadb postgresql
# Check web server performance
sudo systemctl status apache2
# Monitor communication services
sudo systemctl status prosody coturn exim4
๐ Performance Optimization
# Check boot time (find slow services)
systemd-analyze blame
# Monitor failed services
systemctl --failed
# Check service dependencies
systemctl list-dependencies apache2
๐ Conclusion: Your Digital Masterpiece
Your VPS is a beautifully orchestrated system with multiple layers working in harmony! You’ve got:
- ๐๏ธ Solid foundation (systemd core services)
- ๐ก๏ธ Rock-solid security (AppArmor, UFW, SSH)
- ๐พ Dual database power (MariaDB + PostgreSQL)
- ๐ Web serving capability (Apache running, Nginx ready)
- ๐ง Full communication stack (Email, Chat, Video)
- ๐ค Automated maintenance (Updates, scheduling)
- โ๏ธ Cloud integration (Dynamic configuration)
The only “issue” is deciding between Apache and Nginx - but that’s a luxury problem to have! Both are excellent web servers, and having both available gives you flexibility for different projects.
Your server is ready to power websites, applications, communication platforms, and much more. It’s like having a Swiss Army knife of internet services! ๐ฏโจ