Skip to content

Instantly share code, notes, and snippets.

@almiavicas
Last active June 23, 2024 17:33
Show Gist options
  • Save almiavicas/707323018f5e0826667bff0f62f1bcc7 to your computer and use it in GitHub Desktop.
Save almiavicas/707323018f5e0826667bff0f62f1bcc7 to your computer and use it in GitHub Desktop.
Minimal configuration of a wordpress server for EC2 Amazon Linux 2023
#!/bin/bash
# Update the package repository and install necessary packages
sudo dnf update -y
# Install Apache, PHP, and MariaDB
sudo dnf install -y httpd php php-cli php-pdo php-fpm php-mysqlnd
# Start and enable the HTTPD service
sudo systemctl start httpd
sudo systemctl enable httpd
# Download and configure WordPress
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzf latest.tar.gz
sudo rm latest.tar.gz
sudo mv wordpress/* .
sudo rmdir wordpress
sudo chown -R apache:apache /var/www/html
sudo chmod -R 755 /var/www/html
# Create a script to ensure that necessary services start on boot
cat <<EOL | sudo tee /var/www/html/wp-init.sh
#!/bin/bash
# Start HTTPD service
sudo systemctl start httpd
sudo systemctl enable httpd
EOL
# Make the script executable
sudo chmod +x /var/www/html/wp-init.sh
# Add the script to /etc/rc.local so it runs on every boot
echo "/var/www/html/wp-init.sh" | sudo tee -a /etc/rc.local
sudo chmod +x /etc/rc.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment