3 januari 2026 - VPS Hosting Professionalisering¶
Doel¶
Professionalisering van de VPS hosting setup voor alle vier Drupal sites (live, preview, dev, redactie) met focus op security en isolatie. Specifiek:
- PHP-FPM pools per site met dedicated system users
- MySQL socket authenticatie zonder wachtwoorden in settings.php
- Git workflow implementatie met GitHub repository structuur
- Sudo rechten zonder password prompts voor beheerders
Uitgangssituatie¶
Server: Ubuntu Linux, MariaDB 10.11.8, PHP 8.3.6, Apache 2.4
Databases: drupal_live, drupal_preview, drupal_dev, drupal_redactie
Sites: - live.voedingsgeneeskunde.nl - prev.voedingsgeneeskunde.nl - dev.voedingsgeneeskunde.nl - redactie.voedingsgeneeskunde.nl (standalone)
Problemen: - Alle sites draaiden als www-data user (geen isolatie) - MySQL wachtwoorden in plaintext in settings.php - Geen version control voor code - Sudo wachtwoord vereist voor database operaties
Implementatie¶
MySQL User Permissions met Unix Socket Auth¶
System users aangemaakt:
# Voor beheerders
CREATE USER 'j00sd'@'localhost' IDENTIFIED VIA unix_socket;
CREATE USER 'dreojs'@'localhost' IDENTIFIED VIA unix_socket;
GRANT ALL PRIVILEGES ON *.* TO 'j00sd'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'dreojs'@'localhost' WITH GRANT OPTION;
# Voor PHP-FPM pools
CREATE USER 'www-live'@'localhost' IDENTIFIED VIA unix_socket;
CREATE USER 'www-preview'@'localhost' IDENTIFIED VIA unix_socket;
CREATE USER 'www-dev'@'localhost' IDENTIFIED VIA unix_socket;
CREATE USER 'www-redactie'@'localhost' IDENTIFIED VIA unix_socket;
GRANT ALL PRIVILEGES ON drupal_live.* TO 'www-live'@'localhost';
GRANT ALL PRIVILEGES ON drupal_preview.* TO 'www-preview'@'localhost';
GRANT ALL PRIVILEGES ON drupal_dev.* TO 'www-dev'@'localhost';
GRANT ALL PRIVILEGES ON drupal_redactie.* TO 'www-redactie'@'localhost';
Sudo zonder password: /etc/sudoers.d/vps-admins
Git Workflow met GitHub¶
GitHub organisatie: voedingsgeneeskunde
Repository structuur:
- vg-drupal repository met branches:
- main (live.voedingsgeneeskunde.nl)
- preview (prev.voedingsgeneeskunde.nl)
- dev (dev.voedingsgeneeskunde.nl)
- vg-redactie repository met branch:
- main (redactie.voedingsgeneeskunde.nl)
Workflow: 1. Ontwikkeling in dev branch 2. Testing in preview branch 3. Production in main branch 4. Hotfixes direct op betreffende branch
Git cheatsheet: Uitgebreide commandoreferentie beschikbaar in /docs/scripts/git-workflow-cheatsheet.md
PHP-FPM Pools per Site¶
System users aangemaakt:
useradd -r -s /usr/sbin/nologin -g www-data www-live
useradd -r -s /usr/sbin/nologin -g www-data www-preview
useradd -r -s /usr/sbin/nologin -g www-data www-dev
useradd -r -s /usr/sbin/nologin -g www-data www-redactie
PHP-FPM configuraties: /etc/php/8.3/fpm/pool.d/
- live.conf → /run/php/php-fpm-live.sock
- preview.conf → /run/php/php-fpm-preview.sock
- dev.conf → /run/php/php-fpm-dev.sock
- redactie.conf → /run/php/php-fpm-redactie.sock
Elke pool draait als eigen user met eigen socket.
Apache vhost configuratie:
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php-fpm-[site].sock|fcgi://localhost"
</FilesMatch>
Module proxy_fcgi enabled met a2enmod proxy_fcgi.
Drupal settings.php aanpassingen:
'database' => 'drupal_[site]',
'username' => 'www-[site]',
'password' => '', // Leeg!
'host' => 'localhost',
'port' => '3306',
'unix_socket' => '/run/mysqld/mysqld.sock',
File ownership en permissions:
chown -R www-[site]:www-data /var/www/sites/[site]/
find . -type d -exec chmod 2775 {} \;
find . -type f -exec chmod 0664 {} \;
Resultaat¶
Security verbeteringen: - Geen MySQL wachtwoorden meer in settings.php bestanden - Process isolatie: elke site draait als eigen system user - Unix socket authenticatie voor zowel beheerders als applicaties - Sudo toegang zonder password prompts (veilig geconfigureerd)
Git workflow: - Alle code versionbeheerd in GitHub - Duidelijke branch structuur voor dev/preview/live - Redactie standalone met eigen repository - Proper .gitignore voor Drupal (vendor, files, settings.php)
Operationeel: - Alle vier sites bereikbaar via HTTPS - PHP-FPM pools actief en functioneel - MySQL connecties werken via socket authenticatie - Apache proxy_fcgi correct geconfigureerd
Opmerking¶
Installatie verliep opvallend soepel. Enige issue was ontbrekende proxy_fcgi module in Apache, opgelost met a2enmod proxy_fcgi && systemctl reload apache2. Redactie SSL vhost miste initieel PHP-FPM configuratie, toegevoegd aan /etc/apache2/sites-available/d11_redactie-le-ssl.conf.
Documentatie¶
- Git workflow cheatsheet:
/docs/scripts/git-workflow-cheatsheet.md - Alle configuraties gepusht naar GitHub
- Settings.php bestanden lokaal (niet in Git vanwege .gitignore)
Volgende Stappen¶
- Monitoring setup overwegen (PHP-FPM pool status)
- Backup strategie voor databases documenteren
- Composer workflow documenteren in Git cheatsheet