commit dd9936932c3b6ac3f3e7b1eb41a72b0a14ccd922 Author: suricatingss Date: Fri May 29 22:03:51 2026 +0100 initial commit diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..626f204 --- /dev/null +++ b/.env.example @@ -0,0 +1,11 @@ +# 'db' as in the db container. If you chance db container's name, change it here too. +DB_HOST=db + +DB_USER=wordpress +DB_PWD=supersecretpassword + +# name of the database +DB_NAME=wordpress + +# pwd of "root" user. Change this. Seriously. +DB_ROOT_PASSWORD=blowfish \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eebcfa2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.env +stack.env +.DS_Store +Thumbs.db diff --git a/README.md b/README.md new file mode 100644 index 0000000..c6243fa --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# WordPress + Nginx + MariaDB Stack + +A production-ready "Quick Start" stack featuring WordPress running via PHP-FPM and Nginx as a reverse proxy. + +## 🚀 Quick Start + +### 1. Clone the repository +```bash +git clone +cd wp-nginx +``` + +### 2. Setup Environment Variables +This project uses a base + override system for environment variables. +```bash +# Create your local env file from the example +cp .env.example .env +``` +Open `.env` and update your passwords. The `docker-compose.yaml` is configured to load `.env.example` first for defaults and `.env` second for your specific overrides. + +### 3. Launch the Stack +```bash +docker compose up -d +``` + +### 4. Access your site +Visit [http://localhost:8000](http://localhost:8000) in your browser to complete the WordPress installation. + +--- + +## 🛠 Architecture + +- **Web Server:** Nginx (Stable Alpine) +- **Application:** WordPress (PHP 8.5 FPM Alpine) +- **Database:** MariaDB (Latest) + +### Key Features +- **Security:** Nginx configuration is mounted as read-only. +- **Flexibility:** Supports both standard Docker Compose `.env` and Portainer's `stack.env` conventions. +- **Persistence:** Named volumes are used for both database and WordPress content to ensure data survives container restarts. + +## 📂 Project Structure +- `docker-compose.yaml`: The orchestration file. +- `.env.example`: Template for required configuration. +- `nginx/default.conf`: Custom Nginx configuration for PHP-FPM proxying. diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..c728d47 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,48 @@ +services: + db: + image: mariadb:latest + container_name: db + restart: always + env_file: + - .env.example + - .env + environment: + MARIADB_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} + MARIADB_DATABASE: ${DB_NAME} + MARIADB_USER: ${DB_USER} + MARIADB_PASSWORD: ${DB_PWD} + volumes: + - db_data:/var/lib/mysql + + wp: + image: wordpress:php8.5-fpm-alpine + container_name: wp-app + restart: always + env_file: + - .env.example + - .env + depends_on: + - db + environment: + WORDPRESS_DB_HOST: ${DB_HOST} + WORDPRESS_DB_USER: ${DB_USER} + WORDPRESS_DB_PASSWORD: ${DB_PWD} + WORDPRESS_DB_NAME: ${DB_NAME} + volumes: + - wp_data:/var/www/html + + web: + image: nginx:stable-alpine + container_name: wp-web + restart: always + ports: + - "8000:80" + depends_on: + - wp + volumes: + - wp_data:/var/www/html + - ./nginx/default.conf:/etc/nginx/conf.d/default.conf:ro + +volumes: + db_data: + wp_data: diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..a36cb3b --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,31 @@ +server { + listen 80; + listen [::]:80; + + root /var/www/html; + index index.php index.html index.htm; + + server_name localhost; + + location / { + try_files $uri $uri/ /index.php?$args; + } + + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ { + expires max; + log_not_found off; + } + + location ~* \.php$ { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_pass wordpress:9000; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + } + + location ~ \.htaccess { + deny all; + } +}