Basic Server Setup Guide
Purpose: Prepare a Linux server (Amazon Linux or Ubuntu) with hostname, system packages, timezone, utilities, database clients, AWS CLI, and logging setup for applications.1. Set Hostname
Amazon Linux / Ubuntu:2. Update System Packages
Amazon Linux:3. Set Timezone to IST
Amazon Linux / Ubuntu:4. Install Basic Utilities
Amazon Linux:5. Enable SSH Key Authentication (for Jenkins or root access)
6. Install Database Clients
Amazon Linux:7. Install AWS CLI (v2 recommended)
Amazon Linux / Ubuntu:8. Set Up Systemd Service for Applications
Purpose: Run Python or Go apps as systemd services with persistent logging and automatic startup.8.1 Create Service Unit File
Example: Python (FastAPI with uvicorn)8.2 Register & Start Service
8.3 Set Up Logging Directory
8.4 Configure Log Rotation
Create/etc/logrotate.d/<app-name>:
Note on copytruncate:
Ensures Fluent Bit (or any tailing agent) continues reading logs without interruption.
8.5 Force Log Rotation (Testing)
app.log→ fresh, current logapp.log-YYYY-MM-DD.gz→ rotated & compressed
8.6 View Logs
/var/log/<app-name>/app.log, rotated daily, and services start automatically on reboot.
9. Set Up Fluent Bit for Log Collection (to Kibana / S3)
Install Fluent Bit:/etc/fluent-bit/fluent-bit.conf (example):
10. Set Up Logstash to Receive Logs
Example/etc/logstash/conf.d/<app-name>.conf:
- Logstash domain usually works internally in VPC (
logstash.internal.example.co.in). - If Kibana is in another VPC, allow ports (e.g., 5003) via VPC peering.
✅ Outcome:
- Server is fully configured with hostname, packages, timezone, utilities, database clients, AWS CLI.
- Applications run as systemd services with persistent logging.
- Fluent Bit collects logs and forwards them to S3 and Logstash/Kibana reliably.

