Drupal ist ein leistungsstarkes Open-Source-CMS für komplexe Websites und Webanwendungen. Es bietet flexible Content-Strukturen und eignet sich für Enterprise-Projekte.
Warum Drupal?
Vorteile
- Flexible Content-Typen
- Leistungsstarke Taxonomie
- Multilingual integriert
- Rollenbasierte Berechtigungen
- RESTful API
- Große CommunityDrupal vs. WordPress
| Feature | Drupal | WordPress | |---------|--------|-----------| | Komplexität | Hoch | Niedrig | | Lernkurve | Steil | Flach | | Flexibilität | Sehr hoch | Mittel | | Performance | Gut | Variabel | | Enterprise | Ja | Bedingt | | Community | Groß | Sehr groß |
Voraussetzungen
Systemanforderungen
- PHP 8.1+ (8.2 empfohlen)
- MySQL 5.7.8+ / MariaDB 10.3.7+ / PostgreSQL 12+
- Apache oder Nginx
- Composer
- 512 MB RAM (2 GB empfohlen)PHP-Erweiterungen
- gd
- pdo
- pdo_mysql
- mbstring
- xml
- curl
- json
- opcacheVorbereitung
LAMP-Stack installieren
# Apache, MySQL, PHP
apt update
apt install apache2 mariadb-server php php-mysql \
php-gd php-xml php-mbstring php-curl php-zip \
php-opcache php-apcu libapache2-mod-php
# Apache-Module
a2enmod rewrite
a2enmod headersComposer installieren
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
composer --versionDatenbank erstellen
mysql -u root -pCREATE DATABASE drupal CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'drupal'@'localhost' IDENTIFIED BY 'SicheresPasswort!';
GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost';
FLUSH PRIVILEGES;
EXIT;Installation mit Composer
Drupal herunterladen
cd /var/www
composer create-project drupal/recommended-project drupal
# Verzeichnis anpassen
cd drupalDateistruktur
/var/www/drupal/
├── web/ # Document Root
│ ├── core/ # Drupal Core
│ ├── modules/ # Module
│ ├── themes/ # Themes
│ └── sites/ # Sites-Konfiguration
├── vendor/ # PHP-Abhängigkeiten
└── composer.json # Composer-KonfigurationBerechtigungen
chown -R www-data:www-data /var/www/drupal
chmod -R 755 /var/www/drupal
# Schreibrechte für Files-Verzeichnis
mkdir -p /var/www/drupal/web/sites/default/files
chmod 775 /var/www/drupal/web/sites/default/files
# Settings-Datei vorbereiten
cp /var/www/drupal/web/sites/default/default.settings.php \
/var/www/drupal/web/sites/default/settings.php
chmod 644 /var/www/drupal/web/sites/default/settings.phpApache konfigurieren
Virtual Host
# /etc/apache2/sites-available/drupal.conf
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/drupal/web
<Directory /var/www/drupal/web>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/drupal_error.log
CustomLog ${APACHE_LOG_DIR}/drupal_access.log combined
</VirtualHost>a2ensite drupal.conf
a2dissite 000-default.conf
systemctl reload apache2Nginx (Alternative)
# /etc/nginx/sites-available/drupal
server {
listen 80;
server_name example.com www.example.com;
root /var/www/drupal/web;
index index.php;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ \..*/.*\.php$ {
return 403;
}
location ~ ^/sites/.*/private/ {
return 403;
}
location ~ ^/sites/[^/]+/files/.*\.php$ {
deny all;
}
location / {
try_files $uri /index.php?$query_string;
}
location @rewrite {
rewrite ^ /index.php;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires max;
log_not_found off;
}
}Web-Installation
Installation starten
URL: http://example.com
Installationsschritte
1. Sprache wählen: Deutsch
2. Installationsprofil: Standard
3. Datenbank-Konfiguration:
- Typ: MySQL/MariaDB
- Name: drupal
- Benutzer: drupal
- Passwort: SicheresPasswort!
- Host: localhost
4. Website konfigurieren:
- Site-Name
- E-Mail-Adresse
- Admin-Benutzername
- Admin-Passwort
5. Installation abschließenNach der Installation
# Schreibschutz für settings.php
chmod 444 /var/www/drupal/web/sites/default/settings.php
chmod 555 /var/www/drupal/web/sites/defaultDrush (Command-Line-Tool)
Installation
cd /var/www/drupal
composer require drush/drush
# Symlink erstellen
ln -s /var/www/drupal/vendor/bin/drush /usr/local/bin/drushWichtige Befehle
# Status prüfen
drush status
# Cache leeren
drush cache:rebuild
drush cr
# Modul aktivieren
drush en module_name
# Modul deaktivieren
drush pm:uninstall module_name
# Updates prüfen
drush pm:security
# Datenbank aktualisieren
drush updatedb
# Benutzer erstellen
drush user:create username --mail="user@example.com" --password="passwort"
# Passwort zurücksetzen
drush user:password admin "neues-passwort"Module installieren
Per Composer
cd /var/www/drupal
# Modul hinzufügen
composer require drupal/admin_toolbar
composer require drupal/pathauto
# Modul aktivieren
drush en admin_toolbar admin_toolbar_tools pathauto
# Cache leeren
drush crEmpfohlene Module
# Administration
admin_toolbar # Verbessertes Admin-Menü
coffee # Schnellnavigation (Alt+D)
# SEO
pathauto # Automatische URL-Aliase
metatag # Meta-Tags
redirect # URL-Redirects
simple_sitemap # XML-Sitemap
# Editor
ckeditor5 # WYSIWYG-Editor (Core)
paragraphs # Flexible Inhaltsblöcke
media # Medienverwaltung (Core)
# Performance
page_cache # Seitencache (Core)
dynamic_page_cache # Dynamischer Cache (Core)
big_pipe # Progressive Rendering (Core)
# Entwicklung
devel # Entwicklerwerkzeuge
webprofiler # Performance-ProfilerThemes
Theme installieren
composer require drupal/bootstrap5
drush en bootstrap5Theme aktivieren
Appearance → Bootstrap5 → Set as defaultSubtheme erstellen
cd /var/www/drupal/web/themes
mkdir custom
cd custom
mkdir mytheme# mytheme/mytheme.info.yml
name: My Theme
type: theme
description: Custom Theme basierend auf Bootstrap5
core_version_requirement: ^10
base theme: bootstrap5
regions:
header: Header
content: Content
sidebar: Sidebar
footer: FooterContent-Typen
Neuen Content-Typ erstellen
Structure → Content types → Add content type
Name: Produkt
Beschreibung: Produktseiten
Fields:
- Titel (Standard)
- Body (Standard)
- Bild (Image)
- Preis (Decimal)
- Kategorie (Entity Reference → Taxonomy)Taxonomy (Kategorien)
Structure → Taxonomy → Add vocabulary
Name: Produktkategorien
Terme hinzufügen:
- Elektronik
- Kleidung
- MöbelViews erstellen
Structure → Views → Add view
Name: Produktliste
Show: Content of type Produkt
Create a page: /produkte
Display format: GridPerformance-Optimierung
Cache-Einstellungen
Configuration → Development → Performance
- Aggregate CSS files: ✓
- Aggregate JavaScript files: ✓settings.php anpassen
// /var/www/drupal/web/sites/default/settings.php
// Produktionsmodus
$settings['container_yamls'][] = $app_root . '/' . $site_path . '/services.yml';
// Cache-Einstellungen
$settings['cache']['bins']['render'] = 'cache.backend.memory';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.memory';
// CSS/JS Aggregation
$config['system.performance']['css']['preprocess'] = TRUE;
$config['system.performance']['js']['preprocess'] = TRUE;Redis-Cache
# Redis installieren
apt install redis-server php-redis
# Modul installieren
composer require drupal/redis
drush en redis// settings.php
$settings['redis.connection']['interface'] = 'PhpRedis';
$settings['redis.connection']['host'] = '127.0.0.1';
$settings['cache']['default'] = 'cache.backend.redis';OPcache
# /etc/php/8.2/apache2/conf.d/10-opcache.ini
opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.revalidate_freq=60Sicherheit
Security-Updates
# Sicherheitsupdates prüfen
drush pm:security
# Core aktualisieren
composer update drupal/core-recommended --with-dependencies
drush updatedb
drush crTrusted Host Pattern
// settings.php
$settings['trusted_host_patterns'] = [
'^example\.com$',
'^www\.example\.com$',
];Datei-Berechtigungen
# Skript für sichere Berechtigungen
find /var/www/drupal -type d -exec chmod 755 {} \;
find /var/www/drupal -type f -exec chmod 644 {} \;
chmod 444 /var/www/drupal/web/sites/default/settings.php
chown -R www-data:www-data /var/www/drupalBackup
Backup-Skript
#!/bin/bash
# /usr/local/bin/drupal-backup.sh
DATE=$(date +%Y%m%d)
BACKUP_DIR="/backup/drupal"
DRUPAL_DIR="/var/www/drupal"
mkdir -p $BACKUP_DIR
# Datenbank
drush sql:dump --result-file=$BACKUP_DIR/db-$DATE.sql
# Dateien
tar -czf $BACKUP_DIR/files-$DATE.tar.gz $DRUPAL_DIR/web/sites/default/files
# Alte Backups löschen
find $BACKUP_DIR -type f -mtime +30 -deleteRestore
# Datenbank wiederherstellen
drush sql:cli < backup.sql
# Dateien wiederherstellen
tar -xzf files-backup.tar.gz -C /var/www/drupal/web/sites/default/
# Cache leeren
drush crMultilingual
Sprachen hinzufügen
Configuration → Regional and language → Languages → Add language
Sprache: DeutschÜbersetzungen aktivieren
drush en language content_translation localeContent übersetzen
Content → Artikel → TranslateSSL mit Let's Encrypt
apt install certbot python3-certbot-apache
certbot --apache -d example.com -d www.example.com
# Automatische Erneuerung testen
certbot renew --dry-runTroubleshooting
White Screen of Death
# Error-Log prüfen
tail -f /var/log/apache2/drupal_error.log
# PHP-Fehler aktivieren
# settings.php
$config['system.logging']['error_level'] = 'verbose';Cache-Probleme
# Kompletten Cache leeren
drush cr
# Twig-Cache leeren
rm -rf /var/www/drupal/web/sites/default/files/phpBerechtigungsprobleme
chown -R www-data:www-data /var/www/drupal
chmod -R 755 /var/www/drupal/web/sites/default/filesZusammenfassung
| Befehl | Funktion | |--------|----------| | drush cr | Cache leeren | | drush en module | Modul aktivieren | | drush pm:uninstall module | Modul deinstallieren | | drush updatedb | Datenbank-Updates | | drush pm:security | Sicherheitsupdates prüfen | | drush sql:dump | Datenbank-Backup |
Fazit
Drupal ist ein leistungsstarkes CMS für komplexe Anforderungen. Mit Composer und Drush wird die Verwaltung erheblich vereinfacht. Die flexible Content-Architektur ermöglicht maßgeschneiderte Lösungen, erfordert jedoch eine steilere Lernkurve als WordPress. Für Enterprise-Projekte mit komplexen Inhaltsstrukturen ist Drupal die richtige Wahl.