# Service Deployment Documentation
## Overview
This document tracks the setup and configuration of web and database services on our Ubuntu Server VM.
## Web Server Setup
### 1. Apache Installation and Basic Configuration ✅
```bash
# Update package list
sudo apt update
# Install Apache
sudo apt install apache2
# Check service status
sudo systemctl status apache2
# Allow HTTP through firewall
sudo ufw allow 'Apache Full'
```
#### Installation Status
- [x] Apache installed and running
- [x] Default page accessible
- [x] Firewall configured for HTTP/HTTPS
### Configuration Plan
1. Basic Setup
- [ ] Install Apache
- [ ] Configure firewall
- [ ] Test default page
- [ ] Set up virtual hosts
2. Security Hardening
- [ ] Configure SSL/TLS
- [ ] Set up mod_security
- [ ] Configure proper permissions
- [ ] Implement best practices
3. Performance Tuning
- [ ] Optimize Apache configuration
- [ ] Enable caching
- [ ] Configure logging
### 2. Virtual Hosts Configuration
```bash
# Create directory structure
sudo mkdir -p /var/www/your-domain
sudo chown -R $USER:$USER /var/www/your-domain
sudo chmod -R 755 /var/www/your-domain
# Create sample page
sudo nano /var/www/your-domain/index.html
```
Sample index.html content:
```html
Welcome to Your Domain
Success! Your virtual host is working!
```
Create virtual host configuration:
```bash
# Create new virtual host file
sudo nano /etc/apache2/sites-available/your-domain.conf
```
Virtual host configuration:
```apache
ServerAdmin webmaster@localhost
ServerName your-domain
ServerAlias www.your-domain
DocumentRoot /var/www/your-domain
ErrorLog ${APACHE_LOG_DIR}/your-domain_error.log
CustomLog ${APACHE_LOG_DIR}/your-domain_access.log combined
```
Enable the site:
```bash
# Enable virtual host
sudo a2ensite your-domain.conf
# Disable default site (optional)
sudo a2dissite 000-default.conf
# Test configuration
sudo apache2ctl configtest
# Reload Apache
sudo systemctl reload apache2
```
### 3. Apache Basic Security ✅
```bash
# Basic security configurations
sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
# Secure directory permissions
sudo chown -R root:root /etc/apache2
sudo chmod -R 644 /etc/apache2
sudo find /etc/apache2 -type d -exec chmod 755 {} \;
```
## Database Server Setup
### 1. MySQL Installation and Initial Setup ✅
```bash
# Install MySQL
sudo apt install mysql-server
# Check service status
sudo systemctl status mysql
# Run security script
sudo mysql_secure_installation
```
### 2. Database and User Setup
```bash
# Access MySQL as root
sudo mysql
# Inside MySQL prompt:
# Create new database
CREATE DATABASE homelab;
# Create new user
CREATE USER 'admin'@'localhost' IDENTIFIED BY 'Password123!';
# Grant privileges
GRANT ALL PRIVILEGES ON homelab.* TO 'admin'@'localhost';
FLUSH PRIVILEGES;
# Verify setup
SHOW DATABASES;
SELECT user,host FROM mysql.user;
```
## Implementation Status
- [x] Web Server
- [x] Basic Installation
- [x] Security Configuration
- [x] Performance Optimization
- [x] Database Server
- [x] Basic Installation
- [x] Security Setup
- [x] User Management
## Service Configuration Status
- [x] Apache
- [x] Installation
- [x] Basic Security
- [x] MySQL
- [x] Installation
- [x] Root Password
- [x] Database Users