🍎 CrumbForest macOS Setup (M4 + Homebrew)
Komplettes LAMP-Setup für Apple Silicon (M4) mit Homebrew.
🔧 Voraussetzungen
# Homebrew installiert?
brew --version
# Falls nicht:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
📦 1. PHP installieren
# PHP 8.3 (aktuellste stabile Version)
brew install php@8.3
# In PATH einfügen
echo 'export PATH="/opt/homebrew/opt/php@8.3/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/opt/homebrew/opt/php@8.3/sbin:$PATH"' >> ~/.zshrc
source ~/.zshrc
# Verifizieren
php -v
# Sollte zeigen: PHP 8.3.x
# Wichtige Extensions prüfen
php -m | grep -E "(pdo|mysql|mbstring|json|curl)"
PHP-Extensions installieren (falls fehlend)
# Meist schon dabei, aber zur Sicherheit:
brew install php@8.3
# Composer installieren (falls nicht vorhanden)
brew install composer
composer --version
🗄️ 2. MySQL installieren
# MySQL via Homebrew
brew install mysql
# MySQL-Service starten
brew services start mysql
# Verifizieren
mysql --version
# Root-Passwort setzen (beim ersten Start)
mysql_secure_installation
# Empfohlen:
# - Root-Passwort: JA (merken!)
# - Anonymous users entfernen: JA
# - Root remote login verbieten: JA
# - Test-DB entfernen: JA
# - Privileges neu laden: JA
Alternative: MariaDB
# Wenn du MariaDB bevorzugst
brew install mariadb
brew services start mariadb
mariadb-secure-installation
🌐 3. Apache Setup
Option A: Nativer macOS Apache (empfohlen für M4)
# Nativen Apache nutzen (schon installiert)
sudo apachectl -v
# Sollte zeigen: Apache/2.4.x
# Apache starten
sudo apachectl start
# Status prüfen
sudo apachectl status
Option B: Homebrew Apache (falls gewünscht)
# Homebrew Apache installieren
brew install httpd
# Nativen Apache stoppen (wichtig!)
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
# Homebrew Apache starten
brew services start httpd
# Läuft auf Port 8080 (nicht 80!)
curl http://localhost:8080
⚙️ 4. Apache für PHP konfigurieren
A) Nativer macOS Apache + Homebrew PHP
# Apache-Config bearbeiten
sudo nano /etc/apache2/httpd.conf
# Folgende Zeilen suchen und aktivieren (# entfernen):
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
# PHP-Modul hinzufügen (NACH allen LoadModule-Zeilen):
# Suche nach: #LoadModule php_module
# Ersetze mit:
LoadModule php_module /opt/homebrew/opt/php@8.3/lib/httpd/modules/libphp.so
# PHP-Handler hinzufügen (am Ende der Datei):
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
# DirectoryIndex erweitern (suchen und ersetzen):
# Von:
DirectoryIndex index.html
# Nach:
DirectoryIndex index.php index.html
# AllowOverride aktivieren (für .htaccess):
# Suche: AllowOverride None (im <Directory> Block)
# Ersetze mit: AllowOverride All
php.ini erstellen:
# php.ini kopieren
sudo cp /opt/homebrew/etc/php/8.3/php.ini-development /opt/homebrew/etc/php/8.3/php.ini
# php.ini anpassen
nano /opt/homebrew/etc/php/8.3/php.ini
# Wichtige Einstellungen:
upload_max_filesize = 10M
post_max_size = 12M
memory_limit = 256M
date.timezone = Europe/Berlin
display_errors = On # Nur für Development!
B) Homebrew Apache + Homebrew PHP
# Apache-Config bearbeiten
nano /opt/homebrew/etc/httpd/httpd.conf
# Port ändern (optional):
Listen 80 # statt 8080
# PHP-Modul laden (einfügen):
LoadModule php_module /opt/homebrew/opt/php@8.3/lib/httpd/modules/libphp.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
DirectoryIndex index.php index.html
# DocumentRoot anpassen:
DocumentRoot "/opt/homebrew/var/www"
<Directory "/opt/homebrew/var/www">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
🦉 5. CrumbForest konfigurieren
VirtualHost erstellen (Nativer Apache)
# VHosts aktivieren
sudo nano /etc/apache2/httpd.conf
# Zeile aktivieren (# entfernen):
# Include /private/etc/apache2/extra/httpd-vhosts.conf
# VHost-Config erstellen
sudo nano /etc/apache2/extra/httpd-vhosts.conf
# Füge hinzu:
<VirtualHost *:80>
ServerName crumbforest.local
DocumentRoot "/Users/bmt/Documents/crumbforest_naked_scanner_claude/web_root"
<Directory "/Users/bmt/Documents/crumbforest_naked_scanner_claude/web_root">
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog "/Users/bmt/Documents/crumbforest_naked_scanner_claude/logs/error.log"
CustomLog "/Users/bmt/Documents/crumbforest_naked_scanner_claude/logs/access.log" combined
</VirtualHost>
/etc/hosts anpassen
sudo nano /etc/hosts
# Hinzufügen:
127.0.0.1 crumbforest.local
Apache neu starten
# Nativer Apache:
sudo apachectl restart
# Homebrew Apache:
brew services restart httpd
# Syntax checken (vorher):
sudo apachectl configtest
🗄️ 6. MySQL-Datenbank einrichten
# MySQL starten (falls nicht läuft)
brew services start mysql
# Einloggen
mysql -u root -p
# Passwort von mysql_secure_installation
# Datenbanken erstellen
CREATE DATABASE crumbforest CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE crumbforest_test CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# User erstellen
CREATE USER 'crumbforest_user'@'localhost' IDENTIFIED BY 'crumbforest2024';
# Rechte vergeben
GRANT ALL PRIVILEGES ON crumbforest.* TO 'crumbforest_user'@'localhost';
GRANT ALL PRIVILEGES ON crumbforest_test.* TO 'crumbforest_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
# Schema importieren
cd /Users/bmt/Documents/crumbforest_naked_scanner_claude
mysql -u crumbforest_user -p crumbforest < crumbforest_sql/schema.sql
📝 7. CrumbForest konfigurieren
cd /Users/bmt/Documents/crumbforest_naked_scanner_claude
# .env anpassen
nano .env
# Wichtig:
BASE_URL=http://crumbforest.local
DB_HOST=localhost
DB_NAME=crumbforest
DB_USER=crumbforest_user
DB_PASS=crumbforest2024
# Composer Dependencies installieren
composer install
# Logs-Verzeichnis erstellen
mkdir -p logs
chmod 755 logs
# Uploads-Verzeichnis erstellen
mkdir -p uploads
chmod 755 uploads
✅ 8. Testen
# PHP-Info testen
php -r "phpinfo();" | grep -i "configuration file"
# Apache-Syntax prüfen
sudo apachectl configtest
# MySQL-Connection testen
php -r "new PDO('mysql:host=localhost;dbname=crumbforest', 'crumbforest_user', 'crumbforest2024'); echo 'OK';"
# Health-Check
curl http://crumbforest.local/api/health
# Im Browser öffnen
open http://crumbforest.local
🧪 9. PHPUnit Tests ausführen
cd /Users/bmt/Documents/crumbforest_naked_scanner_claude
# Unit-Tests (ohne DB)
./vendor/bin/phpunit --testsuite Unit
# Integration-Tests (mit DB)
./vendor/bin/phpunit --testsuite Integration
# Alle Tests
./vendor/bin/phpunit
🐛 Troubleshooting
Apache startet nicht
# Port 80 bereits belegt?
sudo lsof -i :80
# Prozess killen falls nötig
sudo kill -9 <PID>
# Logs prüfen
tail -f /var/log/apache2/error_log # Nativer Apache
tail -f /opt/homebrew/var/log/httpd/error_log # Homebrew Apache
PHP-Modul nicht geladen
# PHP-Modul-Pfad prüfen
ls -la /opt/homebrew/opt/php@8.3/lib/httpd/modules/libphp.so
# Falls nicht vorhanden:
brew reinstall php@8.3
# Apache-Config prüfen
sudo apachectl -M | grep php
# Sollte zeigen: php_module
MySQL Connection Failed
# MySQL läuft?
brew services list | grep mysql
# Starten falls nötig
brew services start mysql
# Socket-Pfad prüfen
php -r "echo ini_get('pdo_mysql.default_socket');"
# Connection testen
mysql -u crumbforest_user -p crumbforest -e "SELECT 1;"
Permission Denied
# Apache-User herausfinden
ps aux | grep httpd | head -n 1
# macOS: _www
# Permissions setzen (nur Development!)
chmod -R 755 /Users/bmt/Documents/crumbforest_naked_scanner_claude/web_root
chmod 755 /Users/bmt/Documents/crumbforest_naked_scanner_claude/logs
chmod 755 /Users/bmt/Documents/crumbforest_naked_scanner_claude/uploads
.htaccess funktioniert nicht
# mod_rewrite geladen?
sudo apachectl -M | grep rewrite
# AllowOverride All gesetzt?
sudo nano /etc/apache2/httpd.conf
# Suche nach <Directory> und prüfe AllowOverride
📋 Services verwalten
# Status aller Services
brew services list
# Apache
sudo apachectl start
sudo apachectl stop
sudo apachectl restart
sudo apachectl status
# MySQL
brew services start mysql
brew services stop mysql
brew services restart mysql
# PHP-FPM (falls verwendet)
brew services start php@8.3
brew services stop php@8.3
🚀 Nächste Schritte
- ✅ Apache läuft:
sudo apachectl status - ✅ PHP funktioniert:
curl http://crumbforest.local/api/health - ✅ MySQL connected:
mysql -u crumbforest_user -p - ✅ Tests laufen:
./vendor/bin/phpunit
Merksatz: M4 + Homebrew = Native Speed! 🍎🦉