apiVersion: v1
kind: ConfigMap
metadata:
name: wordpress-config
data:
# WordPress configuration
wp-config.php: |
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# Directory configuration
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
# WordPress specific configuration
Require all granted
Require all granted
Require all granted
Require all granted
# Security headers
Header always set X-Content-Type-Options nosniff
Header always set X-Frame-Options DENY
Header always set X-XSS-Protection "1; mode=block"
# Error and access logs
ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined
# Initialization script for WordPress setup
init-wordpress.sh: |
#!/bin/bash
set -e
echo "๐ Starting WordPress initialization..."
# Wait for MariaDB to be ready
echo "โณ Waiting for MariaDB database..."
for i in {1..30}; do
if mysqladmin ping -h localhost -u wordpress -p"mycelium-secure-password-2025" --silent; then
echo "โ
MariaDB is ready!"
break
fi
echo "โณ Waiting for database... (attempt $i/30)"
sleep 2
done
# Create WordPress database if it doesn't exist
echo "๐ Setting up WordPress database..."
mysql -u wordpress -p"mycelium-secure-password-2025" -e "CREATE DATABASE IF NOT EXISTS wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;" 2>/dev/null || true
# Set WordPress permissions
echo "๐ Setting file permissions..."
chown -R www-data:www-data /var/www/html
chmod -R 755 /var/www/html
chmod -R 777 /var/www/html/wp-content 2>/dev/null || true
# Create wp-config.php if it doesn't exist
if [ ! -f /var/www/html/wp-config.php ]; then
echo "๐ Creating WordPress configuration..."
cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php || true
# Update wp-config.php with database settings
sed -i "s/database_name_here/wordpress/g" /var/www/html/wp-config.php
sed -i "s/username_here/wordpress/g" /var/www/html/wp-config.php
sed -i "s/password_here/mycelium-secure-password-2025/g" /var/www/html/wp-config.php
sed -i "s/localhost/localhost/g" /var/www/html/wp-config.php
fi
# Check if WordPress is already installed
if mysql -u wordpress -p"mycelium-secure-password-2025" -e "USE wordpress; SHOW TABLES;" 2>/dev/null | grep -q "wp_options"; then
echo "โ
WordPress is already installed and configured!"
else
echo "โ
WordPress database setup complete!"
echo "๐ WordPress will be available at: http://localhost:80"
echo "๐ Next steps: Complete WordPress setup through the web interface"
fi
echo "๐ WordPress initialization complete!"
---
apiVersion: v1
kind: ConfigMap
metadata:
name: wordpress-mariadb-config
data:
# MariaDB configuration
my.cnf: |
[mysqld]
# Basic settings
bind-address = 0.0.0.0
port = 3306
user = mysql
# Character set and collation
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
# Memory settings (for small deployments)
innodb_buffer_pool_size = 64M
innodb_log_file_size = 16M
innodb_flush_log_at_trx_commit = 1
innodb_flush_method = O_DIRECT
# WordPress optimization
max_connections = 50
max_allowed_packet = 64M
query_cache_size = 16M
query_cache_type = 1
# Security
skip-name-resolve
local-infile = 0
# Logging
log-error = /var/log/mysql/error.log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
# MariaDB initialization script
init-mariadb.sh: |
#!/bin/bash
set -e
echo "๐๏ธ Starting MariaDB initialization..."
# Wait for MariaDB to start
echo "โณ Waiting for MariaDB to start..."
for i in {1..30}; do
if mysqladmin ping -h localhost --silent; then
echo "โ
MariaDB is ready!"
break
fi
echo "โณ Waiting for MariaDB... (attempt $i/30)"
sleep 2
done
# Create WordPress database and user
echo "๐ Creating WordPress database and user..."
mysql -u root << EOF
CREATE DATABASE IF NOT EXISTS wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER IF NOT EXISTS 'wordpress'@'localhost' IDENTIFIED BY 'mycelium-secure-password-2025';
CREATE USER IF NOT EXISTS 'wordpress'@'%' IDENTIFIED BY 'mycelium-secure-password-2025';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'%';
FLUSH PRIVILEGES;
EOF
# Test database connection
echo "๐งช Testing database connection..."
mysql -u wordpress -p"mycelium-secure-password-2025" -e "SELECT 'Database connection successful' as status;" || echo "โ ๏ธ Database connection test failed, but database should be accessible."
echo "โ
MariaDB initialization complete!"