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!"