How to Install Elgg on CentOS 8
If you’re building a community site, you’ve probably heard of Elgg. On a fresh CentOS 8 box it can feel like an obstacle course—especially with SELinux and PHP‑module juggling—but with the right steps it’s painless.
Prerequisites – make sure you’ve got what you need
- A clean CentOS 8 install (x86_64)
- Root or sudo access
- Internet connectivity to pull packages
- Roughly 1 GB of free disk space for Elgg + database
If your host is a VPS, double‑check that it hasn’t locked down outbound ports; you’ll need port 80/443 open.
Install the EPEL repo and essential packages
sudo dnf install epel-release -y
CentOS 8’s base repositories don’t ship PHP‑7.4 or MariaDB by default; EPEL gives you the extras without pulling in unnecessary dependencies.
sudo dnf groupinstall "Development Tools" -y sudo dnf install httpd mariadb-server php php-fpm php-mysqlnd php-xml php-gd php-curl php-json php-mbstring wget unzip -y
Why the group? The “Development Tools” set includes compilers and libraries that some PHP extensions silently need, so you avoid a half‑finished install later.
Start MariaDB, secure it, and make a database for Elgg
sudo systemctl enable --now mariadb sudo mysql_secure_installation
When prompted, set a root password (remember it!). Then:
CREATE DATABASE elgg_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; GRANT ALL PRIVILEGES ON elgg_db.* TO 'elgg_user'@'localhost' IDENTIFIED BY 'strongpassword'; FLUSH PRIVILEGES;
Why the utf8mb4 charset? Elgg’s core stores user‑generated content; using a modern Unicode set avoids those annoying “?” characters when someone posts emojis.
Pull Elgg and unpack it into your web root
cd /var/www sudo wget https://github.com/Elgg/engine/releases/download/4.3/elgg-4.3.zip sudo unzip elgg-4.3.zip sudo mv elgg-* elgg
Why the elgg- rename?* The ZIP always contains a versioned folder; we simplify to /var/www/elgg so Apache can find it.
Set permissions that actually work
cd /var/www/elgg
sudo chown -R apache:apache .
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;
Why this? Apache runs as the apache user on CentOS 8; without these permissions you’ll hit “Permission denied” when Elgg tries to write session data or media uploads.
Tell Apache where Elgg lives
sudo nano /etc/httpd/conf.d/elgg.conf
Paste:
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/elgg"
<Directory "/var/www/elgg">
AllowOverride All
Require all granted
</Directory>
ErrorLog logs/elgg_error_log
CustomLog logs/elgg_access_log combined
</VirtualHost>
Replace example.com with your real domain. Save and exit.
sudo systemctl enable --now httpd
Why the <Directory> block? It allows Elgg’s .htaccess to do its magic (URL rewriting, security headers). If you skip it, the install wizard will complain about missing rewrites.
Tune PHP for Elgg
Create or edit /etc/php-fpm.d/elgg.conf:
[elgg] user = apache group = apache listen = /var/run/php-fpm/elgg.sock listen.owner = apache listen.group = apache listen.allowed_clients = 127.0.0.1 pm = dynamic pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 2 pm.max_spare_servers = 4 php_admin_value[upload_max_filesize] = 20M php_admin_value[memory_limit] = 256M
sudo systemctl enable --now php-fpm
Why the socket? Using a Unix socket instead of TCP keeps traffic local and is slightly faster. The memory limits give Elgg room to run without hitting fatal errors.
Turn on SELinux permissive for the upload dir (optional)
If you hit “Permission denied” when uploading files, try:
sudo setsebool -P httpd_unified 1 sudo chcon -R -t httpd_sys_rw_content_t /var/www/elgg/files
CentOS 8’s SELinux policy is strict by default. Making the uploads folder writable for Apache fixes a common pain point without disabling SELinux entirely.
Finish the install through the web UI
Open http://example.com/ in your browser. You should see the Elgg welcome screen. Follow the wizard:
1. Database – choose MariaDB, enter the credentials you created earlier.
2. Admin account – pick a username and password; remember it.
3. Site settings – set name, theme, etc.
When you hit “Finish”, Elgg creates its tables and writes config/elgg-config.php. If everything looks good, log in as the admin you just created and start customizing your community.
Common pitfalls I’ve seen
| Symptom | Likely cause |
|---|---|
| Site hangs on “Installing…?” | PHP max_execution_time too low. Raise it in php.ini or php-fpm.conf. |
| “Cannot connect to the database” | Wrong credentials or MariaDB not listening. Double‑check your GRANT statements. |
| “Permission denied” when uploading files | SELinux context wrong; run the chcon command above. |
| 404 errors on every page after install | Apache’s mod_rewrite missing. Run sudo dnf install httpd -y and enable it with sudo systemctl restart httpd. |
That’s it—Elgg up and running on CentOS 8 without a fortune teller or an IT consultant. Now you can start adding plugins, tweaking the theme, or building that tight‑knit community you’ve been dreaming of.