WordPress Installation on the AWS Ubuntu 20.04 Instance
Published: 2023-01-13 14:10:54

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ey65jakdgfu5ms0b1n4d.png)


2. 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yaukid2t3vv802w0839q.png)

3. **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.

4. **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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/surb7t88y8ln61tdjcuo.png)

- Now review and launch

- SSH your instance using Putty or command line

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ncs0lwo79fsc7c6keeev.png)

**<u>Prerequisite to setup WordPress</u>**

- 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
```
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 configtest
Result: 
Syntax OK
Now restart apache2
sudo systemctl restart apache2
```

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lyxl42jpgcnyxf4l6y59.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5h6npk8scdniok7eiofn.png)


**Here we have our WordPress website**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wyb2to0yvd83mkn3yypc.png)

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