Lesson 1: The Server Setup (Capstone Part 1)
Congratulations — you've learned all the individual tools. Now it's time to put everything together. In this mission, you'll set up a web application server from scratch, exactly like a DevOps engineer would on Day 1.
The Scenario
CloudCorp is launching a new microservice. Your job:
- Create the directory structure.
- Configure the application.
- Set proper security permissions.
- Write a startup script.
- Launch it!
Step 1: Directory Structure
Every professional project follows a standard layout:
/opt/webapp/
├── public/ → Static files served to users
├── logs/ → Application log files
├── config/ → Configuration and secrets
└── start.sh → Startup script
The -p flag in mkdir creates parent directories automatically:
mkdir -p /opt/webapp/{public,logs,config}
Step 2: Configuration
Store settings in environment files, not hardcoded in scripts:
echo 'PORT=8080\nENV=production' > /opt/webapp/config/app.env
Step 3: Security
Config files often contain secrets (API keys, database passwords). Lock them down:
chmod 600 /opt/webapp/config/app.env # Only owner can read/write
Step 4: Startup Script
Combine everything into an automated launch sequence:
#!/bin/bash
echo "Server starting on port 8080"
echo "$(date)" >> /opt/webapp/logs/startup.log
booting...
Mission Objective
Build and launch your server step by step:
- Lay the foundation: Create the directory structure with
mkdir -p /opt/webapp/{public,logs,config}. - Configure: Create the config file with
echo 'PORT=8080\nENV=production' > /opt/webapp/config/app.env. - Secure: Lock down the config with
chmod 600 /opt/webapp/config/app.env. - Automate: Create and arm the startup script.
- Launch! Run your startup script.