initial commit
This commit is contained in:
11
.env.example
Normal file
11
.env.example
Normal file
@@ -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
|
||||||
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.env
|
||||||
|
stack.env
|
||||||
|
.DS_Store
|
||||||
|
Thumbs.db
|
||||||
45
README.md
Normal file
45
README.md
Normal file
@@ -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 <your-repo-url>
|
||||||
|
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.
|
||||||
48
docker-compose.yaml
Normal file
48
docker-compose.yaml
Normal file
@@ -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:
|
||||||
31
nginx/default.conf
Normal file
31
nginx/default.conf
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user