1.
Step 1: Launch an EC2 Instance
1. Log in to the AWS Management Console.
2. Navigate to EC2 and click on Launch Instances.
3. Select Amazon Linux 2023 AMI (HVM).
4. Choose an instance type (e.g., t2.micro, which is free-tier eligible).
5. Configure the instance:
Enable Auto-assign Public IP.
Set storage size to at least 10GB.
6. Add a security group:
Open HTTP (port 80) and SSH (port 22) to allow inbound traffic.
7. Review and launch the instance, and download the private key file (.pem) to access
the server.
Step 2: Connect to the EC2 Instance
8. connect to your instance:
Step 3: Install LAMP Stack
9. Update the system:
sudo yum update -y
10. Install Apache web server:
sudo yum install -y httpd
sudo systemctl start httpd
sudo systemctl enable httpd
Test by accessing http://<Instance-Public-IP> in your browser. You should see the Apache test page.
11. Install PHP and required modules:
sudo amazon-linux-extras enable php8.2
sudo yum install -y php php-mysqlnd
Install MariaDB (MySQL):
sudo yum install -y mariadb-server
sudo systemctl start mariadb
sudo systemctl enable mariadb
12. Secure MariaDB:
sudo mysql_secure_installation
Set a root password, remove anonymous users, disallow remote root login,
and remove test databases.
Step 4: Create a WordPress Database
13. Log in to MariaDB:
sudo mysql -u root -p
14. Create a database and user for WordPress:
CREATE DATABASE wordpress ;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'yourpassword' ;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost' ;
FLUSH PRIVILEGES ;
EXIT ;
Step 5: Download and Configure WordPress
15. Navigate to the web server root:
cd /var/www/html
16. Download the latest WordPress:
sudo wget https://wordpress.org/latest.tar.gz
17. Extract WordPress:
sudo tar -xzf latest.tar.gz
sudo mv wordpress/* .
sudo rm -rf wordpress latest.tar.gz
18. Set proper permissions:
sudo chown -R apache:apache /var/www/html
sudo chmod -R 755 /var/www/html
19. Configure WordPress:
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php
Update the database details:
define('DB_NAME', 'wordpress');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'yourpassword');
define('DB_HOST', 'localhost');
Step 6: Restart Apache
20. Restart the Apache service:
sudo systemctl restart httpd
Step 7: Complete WordPress Setup in Browser
21. Open a browser and navigate to:
http://<Instance-Public-IP>
22. Follow the WordPress setup wizard to:
Choose a language.
Set the site title, admin username, password, and email.
Finalize the setup.