213 lines
6.9 KiB
YAML
213 lines
6.9 KiB
YAML
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: wordpress-config
|
|
data:
|
|
# WordPress configuration
|
|
wp-config.php: |
|
|
<?php
|
|
define('DB_NAME', 'wordpress');
|
|
define('DB_USER', 'wordpress');
|
|
define('DB_PASSWORD', 'mycelium-secure-password-2025');
|
|
define('DB_HOST', 'localhost');
|
|
define('DB_CHARSET', 'utf8mb4');
|
|
define('DB_COLLATE', '');
|
|
|
|
# Auth keys for security
|
|
define('AUTH_KEY', 'put your unique phrase here');
|
|
define('SECURE_AUTH_KEY', 'put your unique phrase here');
|
|
define('LOGGED_IN_KEY', 'put your unique phrase here');
|
|
define('NONCE_KEY', 'put your unique phrase here');
|
|
define('AUTH_SALT', 'put your unique phrase here');
|
|
define('SECURE_AUTH_SALT', 'put your unique phrase here');
|
|
define('LOGGED_IN_SALT', 'put your unique phrase here');
|
|
define('NONCE_SALT', 'put your unique phrase here');
|
|
|
|
# WordPress configuration
|
|
$table_prefix = 'wp_';
|
|
define('WP_DEBUG', false);
|
|
|
|
# Memory limits
|
|
ini_set('memory_limit', '256M');
|
|
@ini_set('upload_max_filesize', '64M');
|
|
@ini_set('post_max_size', '64M');
|
|
@ini_set('max_execution_time', 300);
|
|
|
|
# WordPress path
|
|
if (!defined('ABSPATH')) {
|
|
define('ABSPATH', __DIR__ . '/');
|
|
}
|
|
|
|
require_once ABSPATH . 'wp-settings.php';
|
|
|
|
# Apache configuration for WordPress
|
|
wordpress.conf: |
|
|
<VirtualHost *:80>
|
|
ServerAdmin webmaster@localhost
|
|
DocumentRoot /var/www/html
|
|
|
|
# Directory configuration
|
|
<Directory /var/www/html>
|
|
Options Indexes FollowSymLinks
|
|
AllowOverride All
|
|
Require all granted
|
|
</Directory>
|
|
|
|
# WordPress specific configuration
|
|
<Directory /var/www/html/wp-admin>
|
|
Require all granted
|
|
</Directory>
|
|
|
|
<Directory /var/www/html/wp-includes>
|
|
Require all granted
|
|
</Directory>
|
|
|
|
<Directory /var/www/html/wp-content/plugins>
|
|
Require all granted
|
|
</Directory>
|
|
|
|
<Directory /var/www/html/wp-content/themes>
|
|
Require all granted
|
|
</Directory>
|
|
|
|
# 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
|
|
</VirtualHost>
|
|
|
|
# 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!" |