admin 2 months ago
commit
d3604a4c4c
6 changed files with 89 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 30 0
      README.md
  3. 5 0
      TEMPLATES/.env
  4. 16 0
      TEMPLATES/conf/mpm_prefork.conf
  5. 32 0
      TEMPLATES/docker-compose.yml
  6. 5 0
      index.php

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+sites/

+ 30 - 0
README.md

@@ -0,0 +1,30 @@
+### Wordpress
+
+### Create a new site
+1. Prepare a DB, see db/README.md 
+2. Copy a new site from the template
+3. Update `.env`
+  - Update the vhost-name
+  - Update the letsencrypt address
+  - Remove example DB config
+  - Copy the DB settings
+4. Start the container `cd sites/<new site>` and `docker-compose up -d`
+
+#### Example
+```
+cd /opt/docker/db/utils/
+create_db.sh wwwexamplecom
+cd /opt/docker/wordpress
+cp -R TEMPLATES/ sites/www.example.com>`
+cd sites/www.example.com
+sed -e 's/<fqdn>/www.example.com/' \
+    -e 's/<site\.tld>/example\.com/' \
+    -e '/^DB.*/d' \
+    .env
+echo "" >> .env #newline
+`cat /opt/docker/db/utils/wwwexamplecom__db.conf >> sites/<new site>/.env
+```
+
+#### Files to backup 
+- /opt/docker/wordpress
+- /opt/db_sqldump

+ 5 - 0
TEMPLATES/.env

@@ -0,0 +1,5 @@
+VIRTUAL_HOST=<fqdn>
+DB_USER=<username>
+DB_PASS=<password> 
+DB_NAME=<database>
+LETSENCRYPT_EMAIL=webmaster+letsencrypt.org@<site.tld>

+ 16 - 0
TEMPLATES/conf/mpm_prefork.conf

@@ -0,0 +1,16 @@
+# prefork MPM
+# StartServers: number of server processes to start
+# MinSpareServers: minimum number of server processes which are kept spare
+# MaxSpareServers: maximum number of server processes which are kept spare
+# MaxRequestWorkers: maximum number of server processes allowed to start
+# MaxConnectionsPerChild: maximum number of requests a server process serves
+
+<IfModule mpm_prefork_module>
+	StartServers		 1 
+	MinSpareServers		 1
+	MaxSpareServers		 3
+	MaxRequestWorkers	 150
+	MaxConnectionsPerChild   0
+</IfModule>
+
+# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

+ 32 - 0
TEMPLATES/docker-compose.yml

@@ -0,0 +1,32 @@
+version: '2'
+
+services:
+  wordpress:
+    container_name: wordpress_${DB_NAME}
+    image: wordpress:latest
+    restart: on-failure:3
+    mem_limit: 200M
+
+    volumes:
+      - ./data:/var/www/html/
+      - ./conf/mpm_prefork.conf:/etc/apache2/mods-available/mpm_prefork.conf
+
+    environment:
+      WORDPRESS_DB_HOST: db:3306
+      WORDPRESS_DB_USER: ${DB_USER}
+      WORDPRESS_DB_PASSWORD: ${DB_PASS} 
+      WORDPRESS_DB_NAME: ${DB_NAME} 
+      VIRTUAL_HOST:  ${VIRTUAL_HOST}
+      LETSENCRYPT_HOST: ${VIRTUAL_HOST}
+      LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
+
+    networks:
+      - reverse-proxy_default
+      - db_default
+        
+
+networks:
+  reverse-proxy_default:
+    external: true
+  db_default:
+    external: true

+ 5 - 0
index.php

@@ -0,0 +1,5 @@
+
+<?php
+print($_SERVER['SERVER_NAME']);
+print(".");
+?>