MSP Medium
4 min readNov 8, 2023

Embark on your digital journey with our step-by-step WordPress setup tutorial. Unlock the power of customization, create stunning websites, and dive into the world of blogging effortlessly. Whether you’re a tech novice or a seasoned pro, our guide ensures a smooth setup process, empowering you to bring your online vision to life with WordPress magic!

In this particular tutorial, we are going to use bash script to pass as user data while creating an EC2 instance. In this way, the WordPress site is already set up in the instance when we launch it.

  • Log in AWS console and select EC2 service from the service catalog.
  • Select “Launch Instance” in EC2 service.
  • Configure the EC2 instance as your needs, here the main thing to consider is that I selected Ubuntu AMI, and also added HTTP and HTTPS service other than what was there.
  • Finally, we need to expand the Additional Settings and scroll down all the way to the end and add the bash Script in User Data section, and launch the instance.

After a few minutes of launch, when we access the public IP address of that instance with HTTP protocol from any browser we can see the setup page for the WordPress site.

If you are more into custom configuring the WordPress setup then you can follow the tutorial from below link:

# Update and upgrade packages
sudo apt update -y && sudo apt upgrade -y
# Install Apache, MySQL, and PHP
sudo apt install -y apache2 mysql-server php libapache2-mod-php php-mysql
# Change the Apache document root directory to /var/www/html/wordpress
sudo sed -i "s/DocumentRoot.*$/DocumentRoot \/var\/www\/html\/wordpress/g" /etc/apache2/sites-available/000-default.conf
# Change the Apache directory settings to allow overrides
sudo sed -i "s/AllowOverride.*$/AllowOverride All/g" /etc/apache2/apache2.conf
# Create a WordPress database and user
sudo mysql -e "CREATE DATABASE wordpress; \
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password'; \
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost'; \
# Download and extract the latest version of WordPress
cd /tmp && curl -LO
tar xzvf latest.tar.gz
sudo mv wordpress /var/www/html/
# Set the correct permissions for the WordPress files
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
# Create a wp-config.php file from the sample file
cd /var/www/html/wordpress
sudo mv wp-config-sample.php wp-config.php
sudo sed -i "s/database_name_here/wordpress/" wp-config.php
sudo sed -i "s/username_here/wordpressuser/" wp-config.php
sudo sed -i "s/password_here/password/" wp-config.php
# Restart Apache
sudo systemctl restart apache2

Author: Sanjeeb Nepal