DEV Community

Usman Ahmad for AWS Community Builders

Posted on • Updated on

WordPress Installation on the AWS Ubuntu 20.04 Instance

Steps:

  • AWS Account

  • Ubuntu 20.04 instance

  • Prerequisite to setup WordPress

  • Final verification of WordPress website

AWS Account: You should have AWS account to perform this task

  1. We are using Ubuntu 20.04 OS to set up WordPress.

Image description

  1. If you are setting up WordPress just for practice then “t2.micro” instance is fine for this work. Otherwise if you have plan to use this instance for real website then you should use instance type according to the expected load/traffic on your website.

Image description

  1. Configure Instances and Add storage options will be remain same (default) but if you are using this instance for your actual website then you should follow AWS best practices.

  2. Configure Security Group we need SSH and HTTP type should be open to the world (*for best practice ssh port 22 should allow just your ip address and after performing your work you should remove it from ingress rule).

Image description

  • Now review and launch

  • SSH your instance using Putty or command line

Image description

Prerequisite to setup WordPress

  • Install php with all packages

  • Install apache2

  • Install mysql-server

Commands: Follow below commands

apt update -y
sudo apt install php libapache2-mod-php php-mysql php-redis
sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
apt install apache2
apt install mysql-server
systemctl enable apache2 mysql
wget -c http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
mkdir /var/www/wordpress
sudo cp -R wordpress /var/www/wordpress
sudo chown -R www-data:www-data /var/www/wordpress
sudo chmod -R 775 /var/www/html/wordpress
sudo mysql -u root
Enter fullscreen mode Exit fullscreen mode

Now we create database, user with password

CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'wppassword';
GRANT ALL PRIVILEGES ON * . * TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
exit
Enter fullscreen mode Exit fullscreen mode

Now we will create .conf file inside site-available

sudo nano /etc/apache2/sites-available/wordpress.conf
Enter fullscreen mode Exit fullscreen mode

Now update the below details in it

<Directory /var/www/wordpress/>
    AllowOverride All
</Directory>
Enter fullscreen mode Exit fullscreen mode

Now run below commands

sudo a2enmod rewrite
Enter fullscreen mode Exit fullscreen mode

Now to test the configurations

sudo apache2ctl configtest
Result: 
Syntax OK
Now restart apache2
sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

Now access the “wp-config.php” file and add the database credentials

Image description

Now we will access WordPress website through our EC2 instance public IP address

Image description

Here we have our WordPress website

Image description

Now you just need to configure with your website details and enjoy :)

Top comments (0)