Skip to content

Deploying Elgg

Introduction

Elgg is an award-winning open-source social networking engine built with PHP that provides a robust framework for creating all kinds of social environments. From campus-wide social networks to internal collaborative platforms, brand-building communications tools, and private intranets, Elgg powers thousands of social communities worldwide.

Key Features

  • 🚀 Rapid Development Framework: Build socially-aware web applications quickly with well-documented APIs
  • 👥 User Management: Complete authentication system with pluggable auth modules
  • 🔐 Security First: Built-in CSRF protection, XSS filters, HMAC signatures, and modern password hashing
  • 🎨 Flexible Theming: Extendable view system with cacheable static assets
  • 📦 Plugin Architecture: 1000+ community plugins available for extended functionality
  • 🌍 Internationalization: Easy localization with Transifex integration support
  • 💬 Social Features: User profiles, activity streams, groups, messaging, and notifications
  • 📁 File Storage: Flexible file storage API with streaming capabilities
  • 🔔 Notifications: On-site and email notifications with third-party integration support
  • 📊 Access Control: Granular content access policies for private networks
  • 🔌 RESTful API: RPC web services for mobile clients and external integrations
  • ⚡ Performance: Memcached and Redis caching support

Tech Stack

  • Backend: PHP 8.1+ with Composer dependency management
  • Database: MySQL 8.0+ or MariaDB 10.4+
  • Web Server: Apache 2.4+ or NGINX 1.18+
  • JavaScript: Modern ES modules with asynchronous Ajax service
  • Email: Laminas Mail for outgoing email
  • Image Processing: Imagine library for image manipulation
  • Security: htmLawed for XSS filtering
  • Caching: Support for Memcached, Redis, and file caching
  • Migrations: Phinx database migrations

Use Cases

  • University Social Networks: Campus-wide platforms for students and faculty
  • Corporate Intranets: Internal collaboration and knowledge sharing
  • Community Platforms: Online communities with forums, blogs, and file sharing
  • Private Social Networks: Secure networks for organizations and groups
  • Learning Management: Educational platforms with social learning features
  • Professional Networks: Industry-specific networking platforms
  • Project Collaboration: Team workspaces with activity tracking
  • Membership Sites: Paid or free membership communities

Why Deploy Elgg on Klutch.sh?

  • Instant Deployment: Deploy from GitHub with automatic Docker detection
  • MySQL Integration: Easy database setup with persistent storage
  • Persistent Volumes: Automatic data and upload directory persistence
  • Scalable Resources: Adjust compute power as your community grows
  • SSL Certificates: Automatic HTTPS with custom domain support
  • Global CDN: Fast content delivery for worldwide users
  • Zero Downtime: Rolling deployments keep your community online
  • Cost-Effective: Pay only for resources you actually use

Prerequisites

Before deploying Elgg, ensure you have:

  • A Klutch.sh account
  • A GitHub account for repository hosting
  • Basic understanding of PHP and MySQL databases
  • (Optional) A custom domain for your social network

Preparing Your Elgg Repository

Creating the Project Structure

Create a new directory for your Elgg deployment:

Terminal window
mkdir elgg-deployment
cd elgg-deployment

Dockerfile for Production Deployment

Create a Dockerfile that sets up Elgg with Apache and PHP:

FROM php:8.2-apache
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libwebp-dev \
libxpm-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install PHP extensions required by Elgg
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
--with-xpm \
&& docker-php-ext-install -j$(nproc) \
pdo_mysql \
mysqli \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
xml
# Enable Apache modules
RUN a2enmod rewrite headers expires
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Download and extract Elgg
ARG ELGG_VERSION=6.3.2
RUN curl -L "https://github.com/Elgg/Elgg/archive/refs/tags/${ELGG_VERSION}.tar.gz" -o elgg.tar.gz \
&& tar -xzf elgg.tar.gz --strip-components=1 \
&& rm elgg.tar.gz
# Install dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Create necessary directories
RUN mkdir -p \
/var/www/html/elgg-config \
/var/www/html/data \
&& chown -R www-data:www-data /var/www/html
# Configure Apache
RUN echo '<Directory /var/www/html/>\n\
Options FollowSymLinks\n\
AllowOverride All\n\
Require all granted\n\
</Directory>' > /etc/apache2/conf-available/elgg.conf \
&& a2enconf elgg
# Update PHP configuration
RUN echo "upload_max_filesize = 50M" >> /usr/local/etc/php/conf.d/uploads.ini \
&& echo "post_max_size = 50M" >> /usr/local/etc/php/conf.d/uploads.ini \
&& echo "memory_limit = 256M" >> /usr/local/etc/php/conf.d/uploads.ini \
&& echo "max_execution_time = 300" >> /usr/local/etc/php/conf.d/uploads.ini
# Set permissions
RUN chown -R www-data:www-data /var/www/html
# Expose port
EXPOSE 80
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD curl -f http://localhost/ || exit 1
# Start Apache
CMD ["apache2-foreground"]

Alternative: Dockerfile with NGINX and PHP-FPM

For better performance with high traffic, use NGINX with PHP-FPM:

FROM php:8.2-fpm-alpine AS php-base
# Install dependencies
RUN apk add --no-cache \
bash \
curl \
git \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libwebp-dev \
libzip-dev \
libxml2-dev \
zip \
unzip
# Install PHP extensions
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
&& docker-php-ext-install -j$(nproc) \
pdo_mysql \
mysqli \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
xml
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directory
WORKDIR /var/www/html
# Download Elgg
ARG ELGG_VERSION=6.3.2
RUN curl -L "https://github.com/Elgg/Elgg/archive/refs/tags/${ELGG_VERSION}.tar.gz" -o elgg.tar.gz \
&& tar -xzf elgg.tar.gz --strip-components=1 \
&& rm elgg.tar.gz
# Install dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Create directories
RUN mkdir -p \
/var/www/html/elgg-config \
/var/www/html/data \
&& chown -R www-data:www-data /var/www/html
# Update PHP-FPM configuration
RUN echo "upload_max_filesize = 50M" >> /usr/local/etc/php/conf.d/uploads.ini \
&& echo "post_max_size = 50M" >> /usr/local/etc/php/conf.d/uploads.ini \
&& echo "memory_limit = 256M" >> /usr/local/etc/php/conf.d/uploads.ini
# NGINX stage
FROM nginx:alpine
# Copy NGINX configuration
COPY <<'EOF' /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name _;
root /var/www/html;
index index.php;
client_max_body_size 50M;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
EOF
# Copy Elgg files from php stage
COPY --from=php-base /var/www/html /var/www/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]

Dockerfile with Custom Configuration

For production deployments with environment-based configuration:

FROM php:8.2-apache
# Install system dependencies
RUN apt-get update && apt-get install -y \
git \
curl \
libpng-dev \
libonig-dev \
libxml2-dev \
libzip-dev \
zip \
unzip \
libfreetype6-dev \
libjpeg62-turbo-dev \
libwebp-dev \
&& apt-get clean
# Install PHP extensions
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
&& docker-php-ext-install -j$(nproc) \
pdo_mysql \
mysqli \
mbstring \
exif \
pcntl \
bcmath \
gd \
zip \
xml
# Enable Apache modules
RUN a2enmod rewrite headers expires
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html
# Download Elgg
ARG ELGG_VERSION=6.3.2
RUN curl -L "https://github.com/Elgg/Elgg/archive/refs/tags/${ELGG_VERSION}.tar.gz" -o elgg.tar.gz \
&& tar -xzf elgg.tar.gz --strip-components=1 \
&& rm elgg.tar.gz
# Install dependencies
RUN composer install --no-dev --optimize-autoloader --no-interaction
# Create directories
RUN mkdir -p \
/var/www/html/elgg-config \
/var/www/html/data \
/var/www/html/cache \
&& chown -R www-data:www-data /var/www/html
# Configure Apache for Elgg
RUN echo '<Directory /var/www/html/>\n\
Options -Indexes +FollowSymLinks\n\
AllowOverride All\n\
Require all granted\n\
</Directory>\n\
<Directory /var/www/html/data/>\n\
Require all denied\n\
</Directory>' > /etc/apache2/conf-available/elgg.conf \
&& a2enconf elgg
# PHP configuration optimizations
RUN { \
echo 'upload_max_filesize = 50M'; \
echo 'post_max_size = 50M'; \
echo 'memory_limit = 256M'; \
echo 'max_execution_time = 300'; \
echo 'max_input_vars = 5000'; \
echo 'date.timezone = UTC'; \
} > /usr/local/etc/php/conf.d/elgg.ini
# Copy custom settings script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Set proper permissions
RUN chown -R www-data:www-data /var/www/html
EXPOSE 80
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
CMD curl -f http://localhost/ || exit 1
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]

Docker Entrypoint Script

Create docker-entrypoint.sh for automated configuration:

#!/bin/bash
set -e
# Wait for database to be ready
until mysqladmin ping -h"$ELGG_DB_HOST" -P"$ELGG_DB_PORT" --silent; do
echo "Waiting for database connection..."
sleep 2
done
# Create settings.php if it doesn't exist
if [ ! -f "/var/www/html/elgg-config/settings.php" ]; then
cat > /var/www/html/elgg-config/settings.php <<EOF
<?php
return [
'dbhost' => getenv('ELGG_DB_HOST'),
'dbport' => getenv('ELGG_DB_PORT') ?: '3306',
'dbname' => getenv('ELGG_DB_NAME'),
'dbuser' => getenv('ELGG_DB_USER'),
'dbpass' => getenv('ELGG_DB_PASS'),
'dbprefix' => getenv('ELGG_DB_PREFIX') ?: 'elgg_',
'dbencoding' => 'utf8mb4',
'wwwroot' => getenv('ELGG_WWWROOT'),
'dataroot' => '/var/www/html/data/',
'cacheroot' => '/var/www/html/cache/',
'site_guid' => getenv('ELGG_SITE_GUID') ?: '',
'simplecache_enabled' => getenv('ELGG_SIMPLECACHE') ?: true,
'system_cache_enabled' => getenv('ELGG_SYSTEMCACHE') ?: true,
'debug' => getenv('ELGG_DEBUG') ?: '',
];
EOF
chown www-data:www-data /var/www/html/elgg-config/settings.php
fi
# Execute the main command
exec "$@"

Make the script executable:

Terminal window
chmod +x docker-entrypoint.sh

Creating .dockerignore

Optimize your Docker build:

# Git
.git
.gitignore
.gitattributes
# Documentation
README.md
CHANGELOG.md
CONTRIBUTING.md
*.md
# Development
.editorconfig
.mailmap
.readthedocs.yml
phpunit.xml.dist
Gruntfile.js
# Dependencies (will be installed in container)
vendor/
node_modules/
# Data directories
data/
cache/
elgg-config/settings.php
# IDE
.vscode
.idea
*.swp
*.swo
# OS files
.DS_Store
Thumbs.db
# Logs
*.log

Environment Variables Configuration

Create .env.example for reference:

Terminal window
# Database Configuration (Required)
ELGG_DB_HOST=mysql-service.klutch.sh
ELGG_DB_PORT=8000
ELGG_DB_NAME=elgg
ELGG_DB_USER=elgg_user
ELGG_DB_PASS=secure_password_here
ELGG_DB_PREFIX=elgg_
# Site Configuration (Required)
ELGG_WWWROOT=https://your-app-name.klutch.sh
ELGG_SITE_GUID=
# Admin Account (For initial setup)
ELGG_ADMIN_USERNAME=admin
ELGG_ADMIN_PASSWORD=secure_admin_password
ELGG_ADMIN_EMAIL=admin@example.com
ELGG_SITE_NAME=My Elgg Community
# Performance Settings
ELGG_SIMPLECACHE=true
ELGG_SYSTEMCACHE=true
# Debug Settings (Set to empty for production)
ELGG_DEBUG=
# Email Configuration (Optional)
ELGG_EMAIL_FROM=noreply@example.com
ELGG_SMTP_HOST=
ELGG_SMTP_PORT=587
ELGG_SMTP_USER=
ELGG_SMTP_PASS=
# Security Settings
ELGG_SECURITY_KEY=generate-random-32-char-key-here
# Session Configuration
ELGG_SESSION_NAME=Elgg
ELGG_SESSION_LENGTH=86400
# File Upload Settings
ELGG_MAX_FILE_SIZE=50M

Deploying Elgg on Klutch.sh

  1. **Set up MySQL Database**

    Before deploying Elgg, you need a MySQL database. You can either:

    For Klutch.sh MySQL deployment:

    Terminal window
    # Note the connection details:
    Host: your-mysql-app.klutch.sh
    Port: 8000
    Database: elgg
    User: elgg_user
    Password: (set during MySQL deployment)
  2. Initialize your Elgg repository:
    Terminal window
    git init
    git add .
    git commit -m "Initial Elgg deployment"
    git branch -M main
    git remote add origin https://github.com/yourusername/elgg-deployment.git
    git push -u origin main
  3. Log into your Klutch.sh dashboard.
  4. Navigate to the **Apps** section and click **"Create App"**.
  5. Configure your Elgg deployment:
    • App Name: elgg (or your preferred name)
    • Repository: Select your Elgg GitHub repository
    • Branch: main (or your deployment branch)
    • Traffic Type: HTTP (for web application)
    • Internal Port: 80 (Apache default port)
    • Region: Choose your preferred deployment region
    • Compute: Minimum Shared CPU (2 vCPU, 4GB RAM recommended for social networks)
    • Instances: 1 (scale up for high traffic)
  6. Add environment variables in the **Environment Variables** section:

    Required Database Variables:

    ELGG_DB_HOST=your-mysql-app.klutch.sh
    ELGG_DB_PORT=8000
    ELGG_DB_NAME=elgg
    ELGG_DB_USER=elgg_user
    ELGG_DB_PASS=your-mysql-password
    ELGG_DB_PREFIX=elgg_

    Required Site Variables:

    ELGG_WWWROOT=https://your-app-name.klutch.sh

    Admin Account (for installation):

    ELGG_ADMIN_USERNAME=admin
    ELGG_ADMIN_PASSWORD=YourSecurePassword123!
    ELGG_ADMIN_EMAIL=admin@example.com
    ELGG_SITE_NAME=My Elgg Community

    Performance Settings:

    ELGG_SIMPLECACHE=true
    ELGG_SYSTEMCACHE=true

    Security:

    ELGG_SECURITY_KEY=generate-a-random-32-character-key
  7. Configure **Persistent Volumes** for data storage:

    Data Volume (User uploads and files):

    • Mount Path: /var/www/html/data
    • Size: 20 GB (adjust based on expected user content)

    Cache Volume (Optional but recommended):

    • Mount Path: /var/www/html/cache
    • Size: 5 GB

    Config Volume (Settings persistence):

    • Mount Path: /var/www/html/elgg-config
    • Size: 1 GB
  8. Click **"Create"** to deploy. Klutch.sh will: - Build your Docker image with Elgg - Install PHP dependencies via Composer - Provision persistent volumes for data - Deploy your Elgg instance - Generate a unique URL: `https://your-app-name.klutch.sh`
  9. Wait for the deployment to complete (typically 3-5 minutes).
  10. Access your Elgg installation wizard at the provided URL.
  11. Complete the web-based installation:
    • Database Settings: Verify auto-filled from environment variables
    • Site Settings: Enter site name, email, and admin account
    • Requirements Check: Ensure all PHP extensions are installed
    • Installation: Click install and wait for database setup
    • Admin Login: Log in with your admin credentials

Post-Installation Configuration

Initial Setup Tasks

After successful installation, complete these essential tasks:

  1. **Verify Site Settings**

    Navigate to AdministrationSettingsBasic Settings:

    • Confirm site name and description
    • Set default language
    • Configure site access (public or members-only)
    • Set default user level for new registrations
  2. **Configure Email**

    Go to AdministrationSettingsEmail Settings:

    Site Email Address: noreply@yourdomain.com
    Email Handler: smtp (for production)
    SMTP Host: smtp.example.com
    SMTP Port: 587
    SMTP Username: your-smtp-username
    SMTP Password: your-smtp-password

    Test email delivery by sending a test email.

  3. **Enable Plugins**

    Navigate to AdministrationConfigurePlugins:

    Core plugins to enable:

    • Activity - User activity streams
    • Blog - Blogging functionality
    • Bookmarks - Social bookmarking
    • Dashboard - User dashboard
    • Discussions - Forum discussions
    • File - File sharing
    • Groups - User groups
    • Messages - Private messaging
    • Pages - Wiki-style pages
    • Profile - User profiles
    • The Wire - Microblogging
    • Web Services - API access
  4. **Configure User Settings**

    AdministrationSettingsUsers:

    • Set minimum password strength
    • Enable/disable public registration
    • Configure username restrictions
    • Set up custom profile fields
    • Configure user validation method
  5. **Set Up Widgets**

    Configure default widgets for:

    • User dashboard
    • User profile sidebars
    • Index page
    • Group profiles

Security Hardening

  1. **Enable HTTPS Only**

    Update ELGG_WWWROOT to use https://:

    Terminal window
    ELGG_WWWROOT=https://your-app-name.klutch.sh
  2. **Configure Security Headers**

    Add to Apache configuration (in Dockerfile):

    Header always set X-Frame-Options "SAMEORIGIN"
    Header always set X-Content-Type-Options "nosniff"
    Header always set X-XSS-Protection "1; mode=block"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
  3. **Set Strong Password Policy**

    AdministrationSettingsSecurity:

    • Minimum password length: 12 characters
    • Require uppercase, lowercase, numbers, and symbols
    • Password expiration: 90 days
    • Prevent password reuse: last 5 passwords
  4. **Enable Two-Factor Authentication**

    Install the 2FA plugin:

    Terminal window
    # Add to your composer.json
    "require": {
    "coldtrick/two_factor_authentication": "*"
    }

    Enable in plugin administration.

  5. **Configure Content Security Policy**

    Add CSP headers to prevent XSS attacks:

    Header always set Content-Security-Policy "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';"
  6. **Limit Login Attempts**

    Install and configure the login throttling plugin to prevent brute force attacks.

Performance Optimization

  1. **Enable Caching**

    AdministrationSettingsAdvanced Settings:

    Simple Cache: Enabled
    System Cache: Enabled

    Clear caches after plugin changes:

    Terminal window
    # Via CLI in container
    php elgg-cli cache:clear
  2. **Configure Redis Caching** (Advanced)

    If using Redis for session storage:

    Terminal window
    # Environment variables
    ELGG_MEMCACHE_SERVERS=redis:6379
    ELGG_SESSION_HANDLER=redis

    Install Redis plugin for Elgg.

  3. **Optimize Database**

    Run database optimization periodically:

    OPTIMIZE TABLE elgg_entities;
    OPTIMIZE TABLE elgg_metadata;
    OPTIMIZE TABLE elgg_annotations;
    OPTIMIZE TABLE elgg_relationships;
  4. **Configure CDN** (Optional)

    For static assets, configure CDN:

    Terminal window
    ELGG_CDN_URL=https://cdn.yourdomain.com
  5. **Image Processing**

    Configure image sizes in AdministrationSettingsAdvanced:

    Large Image Width: 1024
    Medium Image Width: 512
    Small Image Width: 256
    Tiny Image Width: 64

    Enable WebP support for better compression.

Custom Domains

To use your own domain:

  1. Navigate to your app in the Klutch.sh dashboard
  2. Go to **Settings** → **Domains**
  3. Click **"Add Domain"** and enter your domain (e.g., `community.yourdomain.com`)
  4. Add the provided CNAME record to your DNS provider:
    Type: CNAME
    Name: community
    Value: your-app-name.klutch.sh
    TTL: 3600
  5. Wait for DNS propagation (5-30 minutes)
  6. Update `ELGG_WWWROOT` environment variable:
    Terminal window
    ELGG_WWWROOT=https://community.yourdomain.com
  7. Restart your application to apply changes
  8. Clear Elgg cache: **Administration** → **Utilities** → **Clear Cache**

Installing Plugins & Themes

Installing Plugins via Composer

  1. Add plugins to `composer.json` in your repository:
    {
    "require": {
    "elgg/elgg": "^6.3",
    "coldtrick/widget_manager": "*",
    "coldtrick/profile_manager": "*",
    "coldtrick/advanced_notifications": "*",
    "beck24/events": "*",
    "hypeJunction/hypeLists": "*"
    }
    }
  2. Commit and push changes:
    Terminal window
    git add composer.json
    git commit -m "Add Elgg plugins"
    git push origin main
  3. Klutch.sh will automatically rebuild and redeploy
  4. Enable plugins in **Administration** → **Configure** → **Plugins**

User Management:

  • Profile Manager - Enhanced profile customization
  • Widget Manager - Advanced widget configuration
  • User Validation - Email verification for new users

Content & Communication:

  • Events Calendar - Event management and scheduling
  • Poll - Create polls and surveys
  • Advanced Notifications - Enhanced notification system
  • Newsletter - Email newsletters to members

Social Features:

  • Social Login - OAuth login (Facebook, Google, Twitter)
  • Badges - Gamification with user badges
  • Questions & Answers - Q&A community feature
  • Ratings - Content rating system

Media & Files:

  • Album - Photo albums
  • Video - Video embedding and uploading
  • AudioPlayer - Audio file support

Administration:

  • Admin Tools - Enhanced admin utilities
  • Bulk User Admin - Batch user management
  • Advanced Statistics - Detailed analytics
  • Cron Logger - Monitor cron jobs

Installing Themes

  1. Browse themes at Elgg Plugin Directory
  2. Add theme to `composer.json`:
    {
    "require": {
    "coldtrick/aalborg_theme": "*",
    "coldtrick/izap_theme": "*"
    }
    }
  3. Push changes and redeploy
  4. Activate theme in **Administration** → **Configure** → **Plugins**
  5. Configure theme settings in **Administration** → **Configure** → **[Theme Name]**

Backup & Restore

Automated Backup Strategy

  1. **Database Backups**

    Create automated database dumps:

    Terminal window
    # Add to cron or scheduled task
    mysqldump -h your-mysql-app.klutch.sh -P 8000 \
    -u elgg_user -p elgg > elgg-backup-$(date +%Y%m%d).sql
  2. **Volume Snapshots**

    Use Klutch.sh volume snapshots:

    • Navigate to Volumes in dashboard
    • Select your data volume
    • Click “Create Snapshot”
    • Schedule daily snapshots
    • Retain last 7 days minimum
  3. **File Backups**

    Download user-generated content:

    Terminal window
    # Via Klutch.sh volume browser
    Navigate to Volumes Download /var/www/html/data

Manual Backup

  1. **Export Database**

    Access MySQL container:

    Terminal window
    mysqldump elgg > elgg_backup.sql

    Download via Klutch.sh file browser.

  2. **Backup Elgg Data Directory**

    Compress data folder:

    Terminal window
    tar -czf elgg-data-backup.tar.gz /var/www/html/data/
  3. **Backup Configuration**

    Save elgg-config/settings.php and environment variables.

Restore from Backup

  1. **Restore Database**
    Terminal window
    mysql -h your-mysql-app.klutch.sh -P 8000 \
    -u elgg_user -p elgg < elgg_backup.sql
  2. **Restore Data Files**

    Upload backed up data directory to volume:

    • Access Klutch.sh volume browser
    • Navigate to /var/www/html/data
    • Upload files from backup
  3. **Restore Configuration**

    Verify environment variables match backed up settings.

  4. **Clear Cache**

    After restoration:

    Terminal window
    php elgg-cli cache:clear

    Or via admin panel: AdministrationUtilitiesClear Cache

Maintenance & Monitoring

Regular Maintenance Tasks

  1. **Clear Cache Weekly**

    AdministrationUtilitiesClear Cache

    • Simple cache
    • System cache
    • View cache
  2. **Run Cron Jobs**

    Elgg requires cron for scheduled tasks. Add to your Dockerfile:

    # Install cron
    RUN apt-get update && apt-get install -y cron
    # Add Elgg cron job
    RUN echo "*/5 * * * * www-data cd /var/www/html && php elgg-cli cron:run >> /var/log/cron.log 2>&1" >> /etc/crontab
    # Start cron in entrypoint
    RUN echo "cron && apache2-foreground" > /start.sh && chmod +x /start.sh
    CMD ["/start.sh"]

    Or use external cron service to call:

    Terminal window
    curl https://your-app-name.klutch.sh/cron/run/
  3. **Monitor Disk Usage**

    Check volume usage in Klutch.sh dashboard:

    • Data volume should stay below 80% capacity
    • Expand volumes before reaching limits
  4. **Update Plugins**

    Monthly plugin updates:

    Terminal window
    composer update
    git add composer.lock
    git commit -m "Update plugins"
    git push origin main
  5. **Database Optimization**

    Run quarterly:

    OPTIMIZE TABLE elgg_entities;
    OPTIMIZE TABLE elgg_metadata;
    ANALYZE TABLE elgg_entities;

Health Monitoring

  1. **Check Application Health**

    Monitor health endpoint:

    Terminal window
    curl https://your-app-name.klutch.sh/

    Expected: HTTP 200 response

  2. **Monitor Performance**

    Check Klutch.sh metrics:

    • CPU usage (should stay below 70% average)
    • Memory usage (monitor for leaks)
    • Response time (target < 500ms)
    • Error rate (should be < 1%)
  3. **Review Logs**

    Access logs via Klutch.sh dashboard:

    • Application logs: Look for PHP errors
    • Access logs: Monitor traffic patterns
    • Database logs: Watch for slow queries
  4. **User Activity Monitoring**

    AdministrationStatistics:

    • Active users
    • New registrations
    • Content creation rate
    • Popular content

Upgrading Elgg

  1. **Backup Everything**

    Create full backup before upgrading (database + files).

  2. **Update Dockerfile**

    Change Elgg version:

    ARG ELGG_VERSION=6.4.0 # New version
  3. **Update Composer Dependencies**
    Terminal window
    composer update
  4. **Test Locally**

    Build and test locally before deploying:

    Terminal window
    docker build -t elgg-test .
    docker run -p 8080:80 elgg-test
  5. **Deploy Update**
    Terminal window
    git add .
    git commit -m "Upgrade Elgg to 6.4.0"
    git push origin main
  6. **Run Upgrade Script**

    Access upgrade URL:

    https://your-app-name.klutch.sh/upgrade.php

    Follow on-screen instructions.

  7. **Verify Functionality**
    • Test login
    • Check plugins are enabled
    • Verify user content is intact
    • Test posting and interactions

Troubleshooting

Installation Issues

Problem: Elgg installation wizard shows database connection error

Solutions:

  1. Verify MySQL is running and accessible:
    Terminal window
    mysqladmin ping -h your-mysql-app.klutch.sh -P 8000
  2. Check environment variables are correctly set:
    Terminal window
    ELGG_DB_HOST=your-mysql-app.klutch.sh
    ELGG_DB_PORT=8000
  3. Verify MySQL user has proper permissions:
    GRANT ALL PRIVILEGES ON elgg.* TO 'elgg_user'@'%';
    FLUSH PRIVILEGES;
  4. Check network connectivity between containers

Performance Issues

Problem: Slow page load times

Solutions:

  1. Enable all caching:
    Simple Cache: ON
    System Cache: ON
  2. Increase PHP memory limit in Dockerfile:
    RUN echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/elgg.ini
  3. Optimize database:
    OPTIMIZE TABLE elgg_entities;
    OPTIMIZE TABLE elgg_metadata;
  4. Increase compute resources in Klutch.sh:
    Upgrade to: 4 vCPU, 8GB RAM
  5. Consider enabling Redis caching for sessions

File Upload Failures

Problem: Users cannot upload files

Solutions:

  1. Check volume is mounted correctly:
    Terminal window
    # Verify in container
    ls -la /var/www/html/data
  2. Verify directory permissions:
    Terminal window
    chown -R www-data:www-data /var/www/html/data
    chmod -R 755 /var/www/html/data
  3. Check PHP upload limits:
    upload_max_filesize = 50M
    post_max_size = 50M
  4. Verify volume has available space in Klutch.sh dashboard
  5. Check Apache configuration allows file uploads

Plugin Activation Fails

Problem: Plugin won’t activate or throws errors

Solutions:

  1. Check plugin compatibility with your Elgg version
  2. Review plugin dependencies in `composer.json`
  3. Clear all caches:
    Terminal window
    php elgg-cli cache:clear
  4. Check error logs for specific issues:
    Terminal window
    # In Klutch.sh logs panel
    grep -i "error" /var/log/apache2/error.log
  5. Verify plugin files are complete and not corrupted
  6. Try reinstalling plugin via Composer:
    Terminal window
    composer remove vendor/plugin-name
    composer require vendor/plugin-name

Email Not Sending

Problem: Users not receiving notification emails

Solutions:

  1. Verify email settings in **Administration** → **Email Settings**
  2. Test SMTP credentials:
    Terminal window
    telnet smtp.example.com 587
  3. Check email queue:

    AdministrationServerCron

    Verify email cron job is running.

  4. Review email logs for errors
  5. Ensure `ELGG_EMAIL_FROM` is set correctly
  6. Check SPF and DKIM records for your domain

Session Issues

Problem: Users frequently logged out or session errors

Solutions:

  1. Increase session lifetime:
    Terminal window
    ELGG_SESSION_LENGTH=86400 # 24 hours
  2. Check session storage configuration
  3. Verify cookie domain settings match your domain
  4. Clear browser cookies and test
  5. Consider using Redis for session storage for better persistence

High Memory Usage

Problem: Container running out of memory

Solutions:

  1. Increase memory limit:
    RUN echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/elgg.ini
  2. Optimize plugin usage - disable unnecessary plugins
  3. Increase container resources in Klutch.sh dashboard
  4. Review code for memory leaks in custom plugins
  5. Monitor PHP-FPM processes:
    Terminal window
    ps aux | grep php-fpm

Database Connection Pool Exhaustion

Problem: “Too many connections” MySQL error

Solutions:

  1. Increase MySQL max connections
  2. Implement connection pooling
  3. Review and optimize long-running queries
  4. Scale MySQL instance if needed
  5. Check for connection leaks in custom code

Production Best Practices

Security Checklist

  • ✅ HTTPS enforced for all traffic
  • ✅ Strong admin passwords (16+ characters)
  • ✅ Two-factor authentication enabled
  • ✅ Regular security updates applied
  • ✅ File upload restrictions configured
  • ✅ User registration with email verification
  • ✅ Rate limiting on login attempts
  • ✅ Security headers configured
  • ✅ Data directory protected from web access
  • ✅ Regular security audits performed

Performance Checklist

  • ✅ All caching layers enabled
  • ✅ CDN configured for static assets
  • ✅ Database queries optimized
  • ✅ Image compression enabled
  • ✅ Adequate compute resources allocated
  • ✅ Redis/Memcached configured
  • ✅ Lazy loading implemented
  • ✅ Asset minification enabled
  • ✅ HTTP/2 enabled
  • ✅ Regular performance monitoring

Backup Checklist

  • ✅ Daily database backups automated
  • ✅ Weekly volume snapshots
  • ✅ Off-site backup storage
  • ✅ Backup retention policy defined
  • ✅ Restore procedures tested
  • ✅ Configuration backed up
  • ✅ Disaster recovery plan documented
  • ✅ RTO and RPO defined
  • ✅ Backup verification scheduled

Monitoring Checklist

  • ✅ Application health checks configured
  • ✅ Resource usage alerts set up
  • ✅ Error rate monitoring enabled
  • ✅ User activity tracking
  • ✅ Database performance monitoring
  • ✅ Log aggregation configured
  • ✅ Uptime monitoring active
  • ✅ Security event logging
  • ✅ Regular log reviews scheduled

Additional Resources

Official Elgg Resources

Community & Support

Development Resources


Congratulations! You’ve successfully deployed Elgg on Klutch.sh. You now have a powerful social networking platform ready to build your community. Remember to configure security settings, install essential plugins, and set up regular backups! 🚀