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:
mkdir elgg-deploymentcd elgg-deploymentDockerfile for Production Deployment
Create a Dockerfile that sets up Elgg with Apache and PHP:
FROM php:8.2-apache
# Install system dependenciesRUN 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 ElggRUN 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 modulesRUN a2enmod rewrite headers expires
# Install ComposerCOPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directoryWORKDIR /var/www/html
# Download and extract ElggARG ELGG_VERSION=6.3.2RUN 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 dependenciesRUN composer install --no-dev --optimize-autoloader --no-interaction
# Create necessary directoriesRUN mkdir -p \ /var/www/html/elgg-config \ /var/www/html/data \ && chown -R www-data:www-data /var/www/html
# Configure ApacheRUN 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 configurationRUN 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 permissionsRUN chown -R www-data:www-data /var/www/html
# Expose portEXPOSE 80
# Health checkHEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \ CMD curl -f http://localhost/ || exit 1
# Start ApacheCMD ["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 dependenciesRUN apk add --no-cache \ bash \ curl \ git \ libpng-dev \ libjpeg-turbo-dev \ freetype-dev \ libwebp-dev \ libzip-dev \ libxml2-dev \ zip \ unzip
# Install PHP extensionsRUN 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 ComposerCOPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Set working directoryWORKDIR /var/www/html
# Download ElggARG ELGG_VERSION=6.3.2RUN 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 dependenciesRUN composer install --no-dev --optimize-autoloader --no-interaction
# Create directoriesRUN mkdir -p \ /var/www/html/elgg-config \ /var/www/html/data \ && chown -R www-data:www-data /var/www/html
# Update PHP-FPM configurationRUN 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 stageFROM nginx:alpine
# Copy NGINX configurationCOPY <<'EOF' /etc/nginx/conf.d/default.confserver { 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 stageCOPY --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 dependenciesRUN 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 extensionsRUN 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 modulesRUN a2enmod rewrite headers expires
# Install ComposerCOPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/html
# Download ElggARG ELGG_VERSION=6.3.2RUN 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 dependenciesRUN composer install --no-dev --optimize-autoloader --no-interaction
# Create directoriesRUN 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 ElggRUN 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 optimizationsRUN { \ 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 scriptCOPY docker-entrypoint.sh /usr/local/bin/RUN chmod +x /usr/local/bin/docker-entrypoint.sh
# Set proper permissionsRUN 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/bashset -e
# Wait for database to be readyuntil mysqladmin ping -h"$ELGG_DB_HOST" -P"$ELGG_DB_PORT" --silent; do echo "Waiting for database connection..." sleep 2done
# Create settings.php if it doesn't existif [ ! -f "/var/www/html/elgg-config/settings.php" ]; then cat > /var/www/html/elgg-config/settings.php <<EOF<?phpreturn [ '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.phpfi
# Execute the main commandexec "$@"Make the script executable:
chmod +x docker-entrypoint.shCreating .dockerignore
Optimize your Docker build:
# Git.git.gitignore.gitattributes
# DocumentationREADME.mdCHANGELOG.mdCONTRIBUTING.md*.md
# Development.editorconfig.mailmap.readthedocs.ymlphpunit.xml.distGruntfile.js
# Dependencies (will be installed in container)vendor/node_modules/
# Data directoriesdata/cache/elgg-config/settings.php
# IDE.vscode.idea*.swp*.swo
# OS files.DS_StoreThumbs.db
# Logs*.logEnvironment Variables Configuration
Create .env.example for reference:
# Database Configuration (Required)ELGG_DB_HOST=mysql-service.klutch.shELGG_DB_PORT=8000ELGG_DB_NAME=elggELGG_DB_USER=elgg_userELGG_DB_PASS=secure_password_hereELGG_DB_PREFIX=elgg_
# Site Configuration (Required)ELGG_WWWROOT=https://your-app-name.klutch.shELGG_SITE_GUID=
# Admin Account (For initial setup)ELGG_ADMIN_USERNAME=adminELGG_ADMIN_PASSWORD=secure_admin_passwordELGG_ADMIN_EMAIL=admin@example.comELGG_SITE_NAME=My Elgg Community
# Performance SettingsELGG_SIMPLECACHE=trueELGG_SYSTEMCACHE=true
# Debug Settings (Set to empty for production)ELGG_DEBUG=
# Email Configuration (Optional)ELGG_EMAIL_FROM=noreply@example.comELGG_SMTP_HOST=ELGG_SMTP_PORT=587ELGG_SMTP_USER=ELGG_SMTP_PASS=
# Security SettingsELGG_SECURITY_KEY=generate-random-32-char-key-here
# Session ConfigurationELGG_SESSION_NAME=ElggELGG_SESSION_LENGTH=86400
# File Upload SettingsELGG_MAX_FILE_SIZE=50MDeploying Elgg on Klutch.sh
-
**Set up MySQL Database**
Before deploying Elgg, you need a MySQL database. You can either:
- Deploy MySQL on Klutch.sh following our MySQL deployment guide
- Use an external MySQL service
For Klutch.sh MySQL deployment:
Terminal window # Note the connection details:Host: your-mysql-app.klutch.shPort: 8000Database: elggUser: elgg_userPassword: (set during MySQL deployment) -
Initialize your Elgg repository:
Terminal window git initgit add .git commit -m "Initial Elgg deployment"git branch -M maingit remote add origin https://github.com/yourusername/elgg-deployment.gitgit push -u origin main - Log into your Klutch.sh dashboard.
- Navigate to the **Apps** section and click **"Create App"**.
-
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)
- App Name:
-
Add environment variables in the **Environment Variables** section:
Required Database Variables:
ELGG_DB_HOST=your-mysql-app.klutch.shELGG_DB_PORT=8000ELGG_DB_NAME=elggELGG_DB_USER=elgg_userELGG_DB_PASS=your-mysql-passwordELGG_DB_PREFIX=elgg_Required Site Variables:
ELGG_WWWROOT=https://your-app-name.klutch.shAdmin Account (for installation):
ELGG_ADMIN_USERNAME=adminELGG_ADMIN_PASSWORD=YourSecurePassword123!ELGG_ADMIN_EMAIL=admin@example.comELGG_SITE_NAME=My Elgg CommunityPerformance Settings:
ELGG_SIMPLECACHE=trueELGG_SYSTEMCACHE=trueSecurity:
ELGG_SECURITY_KEY=generate-a-random-32-character-key -
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
- Mount Path:
- 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`
- Wait for the deployment to complete (typically 3-5 minutes).
- Access your Elgg installation wizard at the provided URL.
-
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:
-
**Verify Site Settings**
Navigate to Administration → Settings → Basic Settings:
- Confirm site name and description
- Set default language
- Configure site access (public or members-only)
- Set default user level for new registrations
-
**Configure Email**
Go to Administration → Settings → Email Settings:
Site Email Address: noreply@yourdomain.comEmail Handler: smtp (for production)SMTP Host: smtp.example.comSMTP Port: 587SMTP Username: your-smtp-usernameSMTP Password: your-smtp-passwordTest email delivery by sending a test email.
-
**Enable Plugins**
Navigate to Administration → Configure → Plugins:
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
-
**Configure User Settings**
Administration → Settings → Users:
- Set minimum password strength
- Enable/disable public registration
- Configure username restrictions
- Set up custom profile fields
- Configure user validation method
-
**Set Up Widgets**
Configure default widgets for:
- User dashboard
- User profile sidebars
- Index page
- Group profiles
Security Hardening
-
**Enable HTTPS Only**
Update
ELGG_WWWROOTto usehttps://:Terminal window ELGG_WWWROOT=https://your-app-name.klutch.sh -
**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" -
**Set Strong Password Policy**
Administration → Settings → Security:
- Minimum password length: 12 characters
- Require uppercase, lowercase, numbers, and symbols
- Password expiration: 90 days
- Prevent password reuse: last 5 passwords
-
**Enable Two-Factor Authentication**
Install the 2FA plugin:
Terminal window # Add to your composer.json"require": {"coldtrick/two_factor_authentication": "*"}Enable in plugin administration.
-
**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';" -
**Limit Login Attempts**
Install and configure the login throttling plugin to prevent brute force attacks.
Performance Optimization
-
**Enable Caching**
Administration → Settings → Advanced Settings:
Simple Cache: EnabledSystem Cache: EnabledClear caches after plugin changes:
Terminal window # Via CLI in containerphp elgg-cli cache:clear -
**Configure Redis Caching** (Advanced)
If using Redis for session storage:
Terminal window # Environment variablesELGG_MEMCACHE_SERVERS=redis:6379ELGG_SESSION_HANDLER=redisInstall Redis plugin for Elgg.
-
**Optimize Database**
Run database optimization periodically:
OPTIMIZE TABLE elgg_entities;OPTIMIZE TABLE elgg_metadata;OPTIMIZE TABLE elgg_annotations;OPTIMIZE TABLE elgg_relationships; -
**Configure CDN** (Optional)
For static assets, configure CDN:
Terminal window ELGG_CDN_URL=https://cdn.yourdomain.com -
**Image Processing**
Configure image sizes in Administration → Settings → Advanced:
Large Image Width: 1024Medium Image Width: 512Small Image Width: 256Tiny Image Width: 64Enable WebP support for better compression.
Custom Domains
To use your own domain:
- Navigate to your app in the Klutch.sh dashboard
- Go to **Settings** → **Domains**
- Click **"Add Domain"** and enter your domain (e.g., `community.yourdomain.com`)
-
Add the provided CNAME record to your DNS provider:
Type: CNAMEName: communityValue: your-app-name.klutch.shTTL: 3600
- Wait for DNS propagation (5-30 minutes)
-
Update `ELGG_WWWROOT` environment variable:
Terminal window ELGG_WWWROOT=https://community.yourdomain.com - Restart your application to apply changes
- Clear Elgg cache: **Administration** → **Utilities** → **Clear Cache**
Installing Plugins & Themes
Installing Plugins via Composer
-
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": "*"}}
-
Commit and push changes:
Terminal window git add composer.jsongit commit -m "Add Elgg plugins"git push origin main - Klutch.sh will automatically rebuild and redeploy
- Enable plugins in **Administration** → **Configure** → **Plugins**
Popular Plugin Recommendations
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
- Browse themes at Elgg Plugin Directory
-
Add theme to `composer.json`:
{"require": {"coldtrick/aalborg_theme": "*","coldtrick/izap_theme": "*"}}
- Push changes and redeploy
- Activate theme in **Administration** → **Configure** → **Plugins**
- Configure theme settings in **Administration** → **Configure** → **[Theme Name]**
Backup & Restore
Automated Backup Strategy
-
**Database Backups**
Create automated database dumps:
Terminal window # Add to cron or scheduled taskmysqldump -h your-mysql-app.klutch.sh -P 8000 \-u elgg_user -p elgg > elgg-backup-$(date +%Y%m%d).sql -
**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
-
**File Backups**
Download user-generated content:
Terminal window # Via Klutch.sh volume browserNavigate to Volumes → Download /var/www/html/data
Manual Backup
-
**Export Database**
Access MySQL container:
Terminal window mysqldump elgg > elgg_backup.sqlDownload via Klutch.sh file browser.
-
**Backup Elgg Data Directory**
Compress data folder:
Terminal window tar -czf elgg-data-backup.tar.gz /var/www/html/data/ -
**Backup Configuration**
Save
elgg-config/settings.phpand environment variables.
Restore from Backup
-
**Restore Database**
Terminal window mysql -h your-mysql-app.klutch.sh -P 8000 \-u elgg_user -p elgg < elgg_backup.sql -
**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
-
**Restore Configuration**
Verify environment variables match backed up settings.
-
**Clear Cache**
After restoration:
Terminal window php elgg-cli cache:clearOr via admin panel: Administration → Utilities → Clear Cache
Maintenance & Monitoring
Regular Maintenance Tasks
-
**Clear Cache Weekly**
Administration → Utilities → Clear Cache
- Simple cache
- System cache
- View cache
-
**Run Cron Jobs**
Elgg requires cron for scheduled tasks. Add to your Dockerfile:
# Install cronRUN apt-get update && apt-get install -y cron# Add Elgg cron jobRUN echo "*/5 * * * * www-data cd /var/www/html && php elgg-cli cron:run >> /var/log/cron.log 2>&1" >> /etc/crontab# Start cron in entrypointRUN echo "cron && apache2-foreground" > /start.sh && chmod +x /start.shCMD ["/start.sh"]Or use external cron service to call:
Terminal window curl https://your-app-name.klutch.sh/cron/run/ -
**Monitor Disk Usage**
Check volume usage in Klutch.sh dashboard:
- Data volume should stay below 80% capacity
- Expand volumes before reaching limits
-
**Update Plugins**
Monthly plugin updates:
Terminal window composer updategit add composer.lockgit commit -m "Update plugins"git push origin main -
**Database Optimization**
Run quarterly:
OPTIMIZE TABLE elgg_entities;OPTIMIZE TABLE elgg_metadata;ANALYZE TABLE elgg_entities;
Health Monitoring
-
**Check Application Health**
Monitor health endpoint:
Terminal window curl https://your-app-name.klutch.sh/Expected: HTTP 200 response
-
**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%)
-
**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
-
**User Activity Monitoring**
Administration → Statistics:
- Active users
- New registrations
- Content creation rate
- Popular content
Upgrading Elgg
-
**Backup Everything**
Create full backup before upgrading (database + files).
-
**Update Dockerfile**
Change Elgg version:
ARG ELGG_VERSION=6.4.0 # New version -
**Update Composer Dependencies**
Terminal window composer update -
**Test Locally**
Build and test locally before deploying:
Terminal window docker build -t elgg-test .docker run -p 8080:80 elgg-test -
**Deploy Update**
Terminal window git add .git commit -m "Upgrade Elgg to 6.4.0"git push origin main -
**Run Upgrade Script**
Access upgrade URL:
https://your-app-name.klutch.sh/upgrade.phpFollow on-screen instructions.
-
**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:
-
Verify MySQL is running and accessible:
Terminal window mysqladmin ping -h your-mysql-app.klutch.sh -P 8000 -
Check environment variables are correctly set:
Terminal window ELGG_DB_HOST=your-mysql-app.klutch.shELGG_DB_PORT=8000 -
Verify MySQL user has proper permissions:
GRANT ALL PRIVILEGES ON elgg.* TO 'elgg_user'@'%';FLUSH PRIVILEGES;
- Check network connectivity between containers
Performance Issues
Problem: Slow page load times
Solutions:
-
Enable all caching:
Simple Cache: ONSystem Cache: ON
-
Increase PHP memory limit in Dockerfile:
RUN echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/elgg.ini
-
Optimize database:
OPTIMIZE TABLE elgg_entities;OPTIMIZE TABLE elgg_metadata;
-
Increase compute resources in Klutch.sh:
Upgrade to: 4 vCPU, 8GB RAM
- Consider enabling Redis caching for sessions
File Upload Failures
Problem: Users cannot upload files
Solutions:
-
Check volume is mounted correctly:
Terminal window # Verify in containerls -la /var/www/html/data -
Verify directory permissions:
Terminal window chown -R www-data:www-data /var/www/html/datachmod -R 755 /var/www/html/data -
Check PHP upload limits:
upload_max_filesize = 50Mpost_max_size = 50M
- Verify volume has available space in Klutch.sh dashboard
- Check Apache configuration allows file uploads
Plugin Activation Fails
Problem: Plugin won’t activate or throws errors
Solutions:
- Check plugin compatibility with your Elgg version
- Review plugin dependencies in `composer.json`
-
Clear all caches:
Terminal window php elgg-cli cache:clear -
Check error logs for specific issues:
Terminal window # In Klutch.sh logs panelgrep -i "error" /var/log/apache2/error.log - Verify plugin files are complete and not corrupted
-
Try reinstalling plugin via Composer:
Terminal window composer remove vendor/plugin-namecomposer require vendor/plugin-name
Email Not Sending
Problem: Users not receiving notification emails
Solutions:
- Verify email settings in **Administration** → **Email Settings**
-
Test SMTP credentials:
Terminal window telnet smtp.example.com 587 -
Check email queue:
Administration → Server → Cron
Verify email cron job is running.
- Review email logs for errors
- Ensure `ELGG_EMAIL_FROM` is set correctly
- Check SPF and DKIM records for your domain
Session Issues
Problem: Users frequently logged out or session errors
Solutions:
-
Increase session lifetime:
Terminal window ELGG_SESSION_LENGTH=86400 # 24 hours - Check session storage configuration
- Verify cookie domain settings match your domain
- Clear browser cookies and test
- Consider using Redis for session storage for better persistence
High Memory Usage
Problem: Container running out of memory
Solutions:
-
Increase memory limit:
RUN echo "memory_limit = 512M" >> /usr/local/etc/php/conf.d/elgg.ini
- Optimize plugin usage - disable unnecessary plugins
- Increase container resources in Klutch.sh dashboard
- Review code for memory leaks in custom plugins
-
Monitor PHP-FPM processes:
Terminal window ps aux | grep php-fpm
Database Connection Pool Exhaustion
Problem: “Too many connections” MySQL error
Solutions:
- Increase MySQL max connections
- Implement connection pooling
- Review and optimize long-running queries
- Scale MySQL instance if needed
- 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
- Elgg Official Website
- Elgg Documentation
- Elgg GitHub Repository
- Elgg API Reference
- Plugin Directory
- Elgg Showcase
Community & Support
Development Resources
Related Klutch.sh Guides
- Deploying MySQL - Database setup for Elgg
- Custom Domains - Configure your community domain
- Persistent Volumes - Understanding volume management
- Monitoring & Logs - Monitor your social network
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! 🚀