#cloud-config package_update: true package_upgrade: true packages: - apache2 - mysql-server - php - php-mysql - php-curl - php-gd - php-xml - php-mbstring - php-zip - libapache2-mod-php - wget - unzip write_files: - path: /etc/apache2/sites-available/wordpress.conf content: | ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/wordpress AllowOverride All Require all granted ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined runcmd: # Configure MySQL - mysql -e "CREATE DATABASE wordpress;" - mysql -e "CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'StrongPassword123!';" - mysql -e "GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';" - mysql -e "FLUSH PRIVILEGES;" # Download and install WordPress - cd /tmp && wget https://wordpress.org/latest.tar.gz - tar -xzf /tmp/latest.tar.gz -C /var/www/ - chown -R www-data:www-data /var/www/wordpress - chmod -R 755 /var/www/wordpress # Enable Apache modules and sites - a2enmod rewrite - a2ensite wordpress.conf - a2dissite 000-default.conf - systemctl reload apache2