From 0bc7b5b1aa73ece48f756c8c85c98843b7637882 Mon Sep 17 00:00:00 2001 From: PopsicleSnow Date: Tue, 7 Oct 2025 17:58:46 -0700 Subject: [PATCH 1/3] apache for multiple orgs --- WordPress-Docker/Dockerfile | 11 ---- WordPress-Docker/README.md | 77 +++++++++++++++++++--- WordPress-Docker/apache/Dockerfile | 28 ++++++++ WordPress-Docker/apache/httpd-userdir.conf | 20 ++++++ WordPress-Docker/docker-compose.yml | 30 ++++++--- 5 files changed, 138 insertions(+), 28 deletions(-) delete mode 100644 WordPress-Docker/Dockerfile create mode 100644 WordPress-Docker/apache/Dockerfile create mode 100644 WordPress-Docker/apache/httpd-userdir.conf diff --git a/WordPress-Docker/Dockerfile b/WordPress-Docker/Dockerfile deleted file mode 100644 index 95d6a2d..0000000 --- a/WordPress-Docker/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -# Dockerfile (apache-static) -FROM httpd:2.4 - -LABEL maintainer="random@gmail.com" - -# Copy static site into the default Apache document root -COPY ./static-site/ /usr/local/apache2/htdocs/ - -EXPOSE 80 -# httpd base image already starts apache with the correct CMD - diff --git a/WordPress-Docker/README.md b/WordPress-Docker/README.md index 4986abc..a2fd7ed 100644 --- a/WordPress-Docker/README.md +++ b/WordPress-Docker/README.md @@ -1,6 +1,14 @@ # WordPress Docker Setup -This repository provides a Dockerized environment for running WordPress locally using Docker Compose. It's designed for quick development and testing without complex installations. +This repository provides a Dockerized environment for running WordPress Multisite locally using Docker Compose. It mimics the OCF (Open Computing Facility) hosting structure where each student organization gets their own WordPress site accessible via userdir paths. + +## Architecture + +- **Apache Server**: Reverse proxy with `mod_userdir` enabled +- **WordPress Multisite**: Centralized WordPress installation serving all student orgs +- **MariaDB**: Shared database for all WordPress sites +- **User Data**: Shared volume for static content and organization files +- **Structure**: Each org gets a WordPress subsite at `http://localhost:8080/~` ## 🚀 Quick Start @@ -14,23 +22,76 @@ This repository provides a Dockerized environment for running WordPress locally 2. **Build and start the containers:** ```bash - docker-compose up -d + docker-compose up -d --build ``` -3. **Access WordPress:** +3. **Complete WordPress initial setup:** Open your browser and navigate to: ``` - http://localhost:8080 + http://localhost:8081 ``` - Follow the on-screen instructions to complete the WordPress setup. + Follow the on-screen instructions to complete the WordPress installation. -## 🛠️ Project Structure +4. **Enable WordPress Multisite:** -* `docker-compose.yml`: Defines the services, networks, and volumes for the WordPress and MySQL containers. -* `Dockerfile`: Customizes the WordPress image (if applicable). + After completing the basic WordPress setup, run: + + ```bash + ./wp-multisite-setup.sh + ``` + + Follow the interactive prompts to configure WordPress Multisite for OCF student organizations. + +## 🌐 Accessing Sites + +### WordPress Network Admin: +- **Main WordPress site**: http://localhost:8081 +- **Network Admin**: http://localhost:8081/wp-admin/network/ + +### Student Organization Sites: +After creating sites in the WordPress Network Admin, access them via: +- http://localhost:8080/~studentorg1 +- http://localhost:8080/~studentorg2 +- http://localhost:8080/~studentorg3 + +Each org gets: +- Separate admin dashboard +- Own themes and plugins +- Independent content management +- Isolated user permissions + +## 📝 Managing Student Organizations + +### Add a new student org WordPress site: + +1. **Via WordPress Network Admin** (Recommended): + - Go to http://localhost:8081/wp-admin/network/ + - Navigate to **Sites → Add New** + - Site Address: `studentorg4` (creates `/studentorg4/`) + - Site Title: `Student Organization 4` + - Admin Email: `admin@studentorg4.edu` + - Click **Add Site** + +2. **Via WP-CLI** (Advanced): + ```bash + docker exec wp_site wp site create --slug=studentorg4 --title="Student Org 4" --email="admin@studentorg4.edu" + ``` + +### Add static content for an org: +```bash +docker exec -it apache-static bash +mkdir -p /home/neworg/public_html +echo "

New Org Static Content

" > /home/neworg/public_html/index.html +chown -R www-data:www-data /home/neworg +``` + +### View Apache logs: +```bash +docker logs ocf_apache_server +``` ## ⚙️ Managing Containers diff --git a/WordPress-Docker/apache/Dockerfile b/WordPress-Docker/apache/Dockerfile new file mode 100644 index 0000000..8d2a6bf --- /dev/null +++ b/WordPress-Docker/apache/Dockerfile @@ -0,0 +1,28 @@ +# Dockerfile (apache-static) +FROM httpd:2.4 + +LABEL maintainer="random@gmail.com" + +# Enable required Apache modules for user directories and PHP +RUN sed -i \ + -e 's/#LoadModule userdir_module/LoadModule userdir_module/' \ + -e 's/#LoadModule vhost_alias_module/LoadModule vhost_alias_module/' \ + -e 's/#LoadModule rewrite_module/LoadModule rewrite_module/' \ + -e 's/#Include conf\/extra\/httpd-userdir.conf/Include conf\/extra\/httpd-userdir.conf/' \ + /usr/local/apache2/conf/httpd.conf + +# Add custom configuration for user directories +COPY httpd-userdir.conf /usr/local/apache2/conf/extra/httpd-userdir.conf + +# Create example student org directories with basic content +RUN mkdir -p /home/studentorg1/public_html && \ + echo "

Welcome to Student Org 1's OCF Page

This is a test page.

" > /home/studentorg1/public_html/index.html && \ + mkdir -p /home/studentorg2/public_html && \ + echo "

Welcome to Student Org 2's OCF Page

This is a test page.

" > /home/studentorg2/public_html/index.html && \ + mkdir -p /home/studentorg3/public_html && \ + echo "

Welcome to Student Org 3's OCF Page

This is a test page.

" > /home/studentorg3/public_html/index.html + +# Set proper ownership +RUN chown -R www-data:www-data /home + +EXPOSE 80 diff --git a/WordPress-Docker/apache/httpd-userdir.conf b/WordPress-Docker/apache/httpd-userdir.conf new file mode 100644 index 0000000..3ca401c --- /dev/null +++ b/WordPress-Docker/apache/httpd-userdir.conf @@ -0,0 +1,20 @@ +# Settings for user home directories +# +# Required module: mod_userdir + +UserDir /home/*/public_html + +# +# Control access to UserDir directories. +# Mimics OCF structure where user directories are in /home +# + + AllowOverride All + Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec + Require all granted + + # Allow .htaccess usage for student customization + + RewriteEngine On + + diff --git a/WordPress-Docker/docker-compose.yml b/WordPress-Docker/docker-compose.yml index 91bdef3..0f6dbba 100644 --- a/WordPress-Docker/docker-compose.yml +++ b/WordPress-Docker/docker-compose.yml @@ -1,17 +1,28 @@ -version: "3.8" +version: '3.8' + services: - apache-static: + apache: build: - context: . - dockerfile: Dockerfile - container_name: apache-static + context: ./apache ports: - - "8080:80" # static landing page -> http://localhost:8080 + - "8080:80" + volumes: + - userdata:/home + depends_on: + - userdata + container_name: apache-static restart: unless-stopped + userdata: + image: busybox + volumes: + - userdata:/home + container_name: user_data + command: /bin/true + db: image: mariadb:11 - container_name: wp-db + container_name: wp_db environment: MYSQL_ROOT_PASSWORD: rootpass MYSQL_DATABASE: wp_db @@ -23,7 +34,7 @@ services: wordpress: image: wordpress:latest - container_name: wp-site + container_name: wp_site depends_on: - db environment: @@ -32,11 +43,12 @@ services: WORDPRESS_DB_PASSWORD: wp_pass WORDPRESS_DB_NAME: wp_db ports: - - "8081:80" # WordPress site -> http://localhost:8081 + - "8081:80" volumes: - wp_data:/var/www/html restart: unless-stopped volumes: + userdata: db_data: wp_data: -- 2.39.5 From b1de8e8d02432ff66946df49af9f188ec185f01a Mon Sep 17 00:00:00 2001 From: PopsicleSnow Date: Tue, 7 Oct 2025 18:04:24 -0700 Subject: [PATCH 2/3] update readme --- WordPress-Docker/README.md | 73 +++++++++----------------------------- 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/WordPress-Docker/README.md b/WordPress-Docker/README.md index a2fd7ed..81535f6 100644 --- a/WordPress-Docker/README.md +++ b/WordPress-Docker/README.md @@ -1,14 +1,13 @@ # WordPress Docker Setup -This repository provides a Dockerized environment for running WordPress Multisite locally using Docker Compose. It mimics the OCF (Open Computing Facility) hosting structure where each student organization gets their own WordPress site accessible via userdir paths. +This repository provides a Dockerized environment for running WordPress locally using Docker Compose. It's designed for quick development and testing without complex installations. ## Architecture -- **Apache Server**: Reverse proxy with `mod_userdir` enabled -- **WordPress Multisite**: Centralized WordPress installation serving all student orgs -- **MariaDB**: Shared database for all WordPress sites -- **User Data**: Shared volume for static content and organization files -- **Structure**: Each org gets a WordPress subsite at `http://localhost:8080/~` +- **Apache Server**: Single Apache container with `mod_userdir` enabled +- **User Data**: Shared volume containing student org home directories +- **WordPress**: Separate WordPress + MariaDB containers for testing +- **Structure**: Each org has `/home//public_html/` served at `http://localhost:8080/~` ## 🚀 Quick Start @@ -22,10 +21,10 @@ This repository provides a Dockerized environment for running WordPress Multisit 2. **Build and start the containers:** ```bash - docker-compose up -d --build + docker-compose up -d ``` -3. **Complete WordPress initial setup:** +3. **Access WordPress:** Open your browser and navigate to: @@ -33,58 +32,20 @@ This repository provides a Dockerized environment for running WordPress Multisit http://localhost:8081 ``` - Follow the on-screen instructions to complete the WordPress installation. + Follow the on-screen instructions to complete the WordPress setup. -4. **Enable WordPress Multisite:** +### Access sites: +- **Student org sites**: + - http://localhost:8080/~studentorg1 + - http://localhost:8080/~studentorg2 + - http://localhost:8080/~studentorg3 +- **WordPress**: http://localhost:8081 - After completing the basic WordPress setup, run: - - ```bash - ./wp-multisite-setup.sh - ``` - - Follow the interactive prompts to configure WordPress Multisite for OCF student organizations. - -## 🌐 Accessing Sites - -### WordPress Network Admin: -- **Main WordPress site**: http://localhost:8081 -- **Network Admin**: http://localhost:8081/wp-admin/network/ - -### Student Organization Sites: -After creating sites in the WordPress Network Admin, access them via: -- http://localhost:8080/~studentorg1 -- http://localhost:8080/~studentorg2 -- http://localhost:8080/~studentorg3 - -Each org gets: -- Separate admin dashboard -- Own themes and plugins -- Independent content management -- Isolated user permissions - -## 📝 Managing Student Organizations - -### Add a new student org WordPress site: - -1. **Via WordPress Network Admin** (Recommended): - - Go to http://localhost:8081/wp-admin/network/ - - Navigate to **Sites → Add New** - - Site Address: `studentorg4` (creates `/studentorg4/`) - - Site Title: `Student Organization 4` - - Admin Email: `admin@studentorg4.edu` - - Click **Add Site** - -2. **Via WP-CLI** (Advanced): - ```bash - docker exec wp_site wp site create --slug=studentorg4 --title="Student Org 4" --email="admin@studentorg4.edu" - ``` - -### Add static content for an org: +### Add new student org: ```bash -docker exec -it apache-static bash +docker exec -it ocf_apache_server bash mkdir -p /home/neworg/public_html -echo "

New Org Static Content

" > /home/neworg/public_html/index.html +echo "

New Org

" > /home/neworg/public_html/index.html chown -R www-data:www-data /home/neworg ``` -- 2.39.5 From 69eaffcc4c11ccd05faf690e52ba7442d2f07138 Mon Sep 17 00:00:00 2001 From: PopsicleSnow Date: Tue, 7 Oct 2025 18:07:58 -0700 Subject: [PATCH 3/3] udpate readme --- WordPress-Docker/README.md | 10 +++++++--- WordPress-Docker/docker-compose.yml | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/WordPress-Docker/README.md b/WordPress-Docker/README.md index 81535f6..5b3a2b8 100644 --- a/WordPress-Docker/README.md +++ b/WordPress-Docker/README.md @@ -16,15 +16,19 @@ This repository provides a Dockerized environment for running WordPress locally ```bash git clone https://git.1337.berkeley.edu/Committee/Secure-OCF-Web-Hosting.git cd Secure-OCF-Web-Hosting/WordPress-Docker - ```` + ``` -2. **Build and start the containers:** +2. **Install Docker Desktop:** + - [macOS](https://docs.docker.com/desktop/setup/install/mac-install/) + - [Windows](https://docs.docker.com/desktop/setup/install/windows-install/) + +3. **Build and start the containers:** ```bash docker-compose up -d ``` -3. **Access WordPress:** +4. **Access WordPress:** Open your browser and navigate to: diff --git a/WordPress-Docker/docker-compose.yml b/WordPress-Docker/docker-compose.yml index 0f6dbba..f54b632 100644 --- a/WordPress-Docker/docker-compose.yml +++ b/WordPress-Docker/docker-compose.yml @@ -43,7 +43,7 @@ services: WORDPRESS_DB_PASSWORD: wp_pass WORDPRESS_DB_NAME: wp_db ports: - - "8081:80" + - "8081:80" # WordPress site -> http://localhost:8081 volumes: - wp_data:/var/www/html restart: unless-stopped -- 2.39.5