Archived
3.7 KiB
3.7 KiB
Secure OCF-Style Multi-User WordPress Hosting Platform
A Docker-based hosting platform modeled after UC Berkeley's Open Computing Facility (OCF), enabling multiple users to host their own WordPress sites through a shared infrastructure with isolated volumes.
Each user volume contains:
site_conf/- Apache vhost configurationwordpress_content/- WordPress files (themes, plugins, uploads)database/- SQL dumps and backups
Quick Start
1. Build and Start Services
# Build and start all services
docker-compose up -d --build
# Check service status
docker-compose ps
# View logs
docker-compose logs -f apache
2. Access Your Test Site
Add this entry to /etc/hosts (or C:\Windows\System32\drivers\etc\hosts on Windows):
127.0.0.1 localhost testuser.local
Then visit:
- Test Site: http://localhost (shows PHP info)
- phpMyAdmin: http://localhost:8080 (user:
wp_user, password:wp_password)
3. Register a New User
# Register a new user with their domain
./register_user.sh alice alice.local
# The script will:
# - Create volume structure
# - Download WordPress
# - Generate vhost configuration
# - Provide next steps
After running the script, you need to:
-
Add the volume to
docker-compose.yml:volumes: - ./volumes/data2-volume:/var/www/data2 -
Restart Apache:
docker-compose restart apache -
Add DNS entry to
/etc/hosts:127.0.0.1 alice.local -
Visit the site: http://alice.local
📁 Project Structure
Secure-OCF-Web-Hosting/
├── apache/
│ ├── Dockerfile # PHP 8.2 + Apache image
│ ├── conf/
│ │ └── httpd.conf # Main Apache config
│ └── vhost-templates/
│ └── user_vhost.template # Template for user sites
├── wordpress/
│ ├── Dockerfile # (Legacy - now Apache handles PHP)
│ └── wp-config.php # (Legacy)
├── volumes/
│ └── data1-volume/ # User volumes
│ ├── site_conf/
│ │ └── site.conf # User's Apache vhost
│ ├── wordpress_content/ # WordPress installation
│ └── database/ # SQL dumps
├── docker-compose.yml # Service orchestration
├── register_user.sh # User registration script
└── README.md # This file
🛠️ Management Commands
Container Management
docker-compose up -d
docker-compose down
docker-compose restart apache
docker-compose logs -f [service_name]
docker-compose exec apache bash
Database Management
docker-compose exec db mysql -u wp_user -p
docker-compose exec db mysqldump -u wp_user -p wp_master > backup.sql
docker-compose exec -T db mysql -u wp_user -p wp_master < backup.sql
User Site Management
ls -la volumes/
docker-compose exec apache apachectl configtest
docker-compose exec apache apachectl graceful
docker-compose exec apache php -v
cat volumes/data1-volume/site_conf/error.log
📝 Environment Variables
Create a .env file for customization:
# Database Configuration
MYSQL_ROOT_PASSWORD=your_secure_root_password
MYSQL_DATABASE=wp_master
MYSQL_USER=wp_user
MYSQL_PASSWORD=your_secure_password
# Apache Configuration
APACHE_HTTP_PORT=80
APACHE_HTTPS_PORT=443
# phpMyAdmin
PMA_PORT=8080
Then update docker-compose.yml to use these variables.