You can use the same instance and RDS which was created in the previous blog :) OR You can create a new one instead.
I'm creating a new RDS :)
Step 1: Start the instance, and connect it through SSH.
Step 2: Install and Configure WordPress on Your EC2 Instance
sudo apt update
sudo apt install apache2 php mysql-client
Step 3: Download and install WordPress. Use wget
or curl
to download the latest WordPress package
cd /var/www/html
sudo wget https://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz
sudo mv wordpress/* /var/www/html/
Step 4: Create a MySQL database for WordPress and a user with appropriate permissions on your RDS instance. Use the MySQL client on your EC2 instance:
mysql -h RDS_ENDPOINT -u MASTER_USERNAME -p
Step 5: Then, in the MySQL client, create a new database and user, and grant the necessary privileges
CREATE DATABASE wordpress;
CREATE USER 'wordpressuser'@'%' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Step 6: Configure the WordPress configuration file
sudo mv wp-config-sample.php wp-config.php
sudo vim wp-config.php
Update the database settings in wp-config.php
:
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'Yourpassword');
define('DB_HOST', 'RDS_ENDPOINT');
Save the file. (ECS:wq Enter )
Step 7: Set the correct permissions for your WordPress files and folders:
sudo chown -R www-data:www-data /var/www/html
Step 8: Start the Apache web server
sudo systemctl start apache2
Step 9: Enable the Apache service to start at boot
sudo systemctl enable apache2
Step 10: Open a web browser and access your EC2 instance's public IP or DNS address to complete the WordPress installation by following the on-screen instructions.
Thank you so much for reading
Follow me on LinkedIn to see interesting posts like this : )