Raza Logo White Small

How to install WordPress on EC2 AWS

Share This Post

To install WordPress on an EC2 instance you can follow these general steps:

  1. Launch an EC2 instance using the Amazon Linux AMI.
  2. Connect to the EC2 instance using SSH.
  3. Install the necessary packages for WordPress by running the following command: sudo yum install -y httpd php php-mysqlnd
  4. Download the latest version of WordPress by running the following command: wget https://wordpress.org/latest.tar.gz
  5. Extract the downloaded file by running the following command: tar -xvzf latest.tar.gz
  6. Move the extracted files to the Apache document root directory by running the following command: sudo mv wordpress/* /var/www/html/
  7. Create a MySQL database and user for WordPress by running the following commands:

 

  1. Run the WordPress installation script by navigating to the following URL in a web browser: http://your-ec2-instance-public-ip/wp-admin/install.php
  2. Fill out the form fields on the installation page, including the database name, user, and password that you created in

Launch an Amazon EC2 instance using the Amazon Linux or Ubuntu AMI.

Connect to your EC2 instance using SSH.

Update the package list and install the latest version of LAMP (Linux, Apache, MySQL, and PHP) by running the following commands:

sudo yum update -y

sudo yum install -y httpd24 php72 mysql57-server php72-mysqlnd

Start the Apache and MySQL services and enable them to start automatically at boot time by running the following commands:

sudo service httpd start

sudo service mysqld start

sudo chkconfig httpd on

sudo chkconfig mysqld on

Secure the MySQL installation by running the following command:

sudo mysql_secure_installation

Create a new MySQL database and user for WordPress by running the following commands:

mysql -u root -p

CREATE DATABASE wordpress;

CREATE USER ‘wordpress’@’localhost’ IDENTIFIED BY ‘password’;

GRANT ALL PRIVILEGES ON wordpress.* TO ‘wordpress’@’localhost’;

FLUSH PRIVILEGES;

EXIT;

Download the latest version of WordPress from the official website and extract it to the Apache document root directory by running the following commands:

cd /var/www/html

wget https://wordpress.org/latest.tar.gz

tar -xzvf latest.tar.gz

Create a new wp-config.php file by running the following command:

cp wordpress/wp-config-sample.php wordpress/wp-config.php

Edit the wp-config.php file and update the database configuration, by running the following command

nano wordpress/wp-config.php

Access the WordPress installation by opening the following URL in your web browser:

http://your-ec2-instance-public-ip/wordpress

You can check the logs for troubleshoot any issues

tail -f /var/log/httpd/error_log

Please note that you should take security measures to secure your EC2 instance and your WordPress installation as well.