WordPress Installation on the AWS Ubuntu 20.04 Instance

Syedusmanahmad
3 min readJun 3, 2021

--

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

  • We are using Ubuntu 20.04 OS to set up WordPress.
  • 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.
For testing purposes we are using “t2.micro” instance type
  • 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.
  • 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).
We allowed 0.0.0.0/0 but its not save for the SSH port 22
  • Now review and launch
  • SSH your instance using Putty or command line

Prerequisite to setup WordPress

  • Install php with all packages
  • Install apache2
  • Install mysql-server

Commands: Follow below commands

apt update -ysudo apt install php libapache2-mod-php php-mysql php-redissudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zipapt install apache2apt install mysql-serversystemctl enable apache2 mysqlwget -c http://wordpress.org/latest.tar.gztar -xzvf latest.tar.gzmkdir /var/www/wordpresssudo cp -R wordpress /var/www/wordpresssudo chown -R www-data:www-data /var/www/wordpresssudo chmod -R 775 /var/www/html/wordpresssudo mysql -u root

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

Now we will create .conf file inside site-available

sudo nano /etc/apache2/sites-available/wordpress.conf

Now update the below details in it

<Directory /var/www/wordpress/>
AllowOverride All
</Directory>

Now run below commands

sudo a2enmod rewrite

Now to test the configurations

sudo apache2ctl configtestResult: Syntax OKNow restart apache2sudo systemctl restart apache2

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

Update your database details

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

Access with your machine public ip address

Here we have our WordPress website

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

--

--

Syedusmanahmad
Syedusmanahmad

Written by Syedusmanahmad

AWS & DevOps Architect | Linux, Docker, Kubernetes, Terraform, Jenkins, Git&GitHub, Ansible expert

Responses (1)