# Easy Installation and Configuration of WordPress on AWS Lightsail

Today I want to share how to install and configure wordpress on AWS lightsail. In this scenario I used Ubuntu 24.04, MySQL for database and wordpress version 6.8.3.

The first thing I create Lightsail and use ubuntu 24.04.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762423496528/fe095158-b6bd-48fa-860c-2e3e33afd1fd.jpeg align="center")

I chose operating system ( OS ) only. You don’t need to select Apps + OS. If you want to get automatic wordpress installed on Lightsail you can chose in Apps + OS section. But in this scenario I only select OS only and deploy wordpress on this lightsail.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762423563528/67ac385a-1277-4742-8824-b4184ed491b6.jpeg align="center")

In this place you can chose many options, base upon your use cases. Your server workload is depend on high memory cosume you need to chose memory selection. CPU is also same like that. But for this now I chose only general lightsail type.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762423612411/12facf70-99f5-400d-9825-603dc25fb886.jpeg align="center")

For best practice you should define key value for filter the resources.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762425744037/b4beee81-8c63-4668-9c7d-d55a60636895.jpeg align="center")

Now you can see our lightsail is running state. For lightsail installation is end in here. Next step we will install and setup wordpress on this server.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762426246020/87004f45-75a0-49a2-a57b-fe94639fe76c.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762426537888/063dfcce-a47d-42f1-ba28-c8946293f7f2.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762540314355/a8deae08-a462-4202-81f3-17c0f3fce154.jpeg align="center")

After server is running state go to networking session. You see my public IPv4, that is not static IP in real world production we must need to attach static ip. In this scenario I don’t use static ip. And then I add HTTPS rule in IPv4 firewall because I want to access my wordpress webiste via https. Another thing you need to restrict ssh access. You don’t need to allow ssh access from anywhere. You should define which ip is only access for ssh remote.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762540840046/e736442d-2186-4d60-a10d-152cfbdcbabc.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762540866972/626b939e-202c-4f45-9327-7320722fc7eb.jpeg align="center")

After you define firewall rule in network session connect your lightsail. You can access 2 ways the first way is using connect using SSH via web browser. The second way is using ssh key. I this scenario I use ssh key authentication. Below photo is using connect using SSH. You can directly connect yuor lightsail via browser.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762541056014/df5dd46d-304f-49e3-a869-11d1905851bc.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762541187483/148a7538-e521-4b22-a643-60e3a5382a9a.jpeg align="center")

I change my tst-svr.pem file’s permission. And then I connect my lightsail via ssh key. After login successful I update the system. And then I download wordpress. And then unzip this file.

```plaintext
sudo chmod 400 tst-svr.pem
ssh -i tst-svr.pem ubuntu@(server ip )
sudo apt update && sudo apt upgrade -y
wget https://wordpress.org/latest.zip
unzip latest.zip
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762541488712/38c63588-2363-43cf-bc6e-d5408d5272d7.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762541864945/31704fe2-7998-4d0d-8341-4f660f31141c.jpeg align="center")

After unzip process install require packages.

```plaintext
sudo apt install nginx mysql-server php-fpm php-mysql php-curl php-gd php-mbstring php-xml pho-xmlrpc pho-soap php-intl php-zip -y
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762542085023/f1da5273-9e42-4ec6-af8d-c162517d53a5.jpeg align="center")

After install packages start and enable service.

```plaintext
sudo systemctl start nginx
sudo systemctl enable nginx

sudo systemctl start mysql
sudo systemctl enable mysql
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762542367648/6a18ff75-70d0-4dda-8c87-7d0438ce7881.jpeg align="center")

After start and enable services configure mysql database.

```plaintext
sudo mysql_secure_installation 
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762542387129/04cb6600-7b25-4476-93bd-69bae4d61be8.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762542490047/31e1a13d-1cae-4b4e-8017-1a4d354a762e.jpeg align="center")

After configure mysql database create database for wordpress.

```plaintext
sudo mysql -u root -p

CREATE DATABASE wordpress;

CREATE USER ‘wpuser’@’localhost’ IDENTIFIED BY ‘dbadmin123’;

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

FLUSH PRIVILEGES;

EXIT;
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762542518299/2eb10db0-7ce0-465b-b53b-a8385c6905b7.jpeg align="center")

After create database for wordpress let’s configure wordpress. Move wordpress directory to /var/www/html location and change ownership and define permissions.

```plaintext
sudo mv wordpress/ /var/www/html/

sudo chown -R www-data:www-data /var/www/html/wordpress/

sudo chmod -R 755 /var/www/html/wordpress/
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762543556056/8cad2d44-3849-4383-8aef-0fd54a0ccf67.jpeg align="center")

copy wp-config-sample.php to wp-config.php and then define DB\_NAME, DB\_USER, DB\_PASSWORD, DB\_HOST in this wp-config.php file.

```plaintext
sudo cp wp-config-sample.php wp-config.php

sudo vi wp-config.php
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762543824349/4b97e07b-8c1a-45c0-8cdc-cac2b3b50a14.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762544082929/43e7d92d-0da9-4148-ab2e-6821fc3becd7.jpeg align="center")

After define DB info in wp-config. Let’s configure ngninx web server side.

```plaintext
sudo vi /etc/nginx/sites-available/wordpress
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762544314145/29d7eca8-becb-4fca-91d0-3ae7dce8f3cf.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762544326867/470a3962-5dde-4ef7-96d7-a011e60c4c58.jpeg align="center")

```nginx
server {
    listen 80;
    server_name your-domain;

    root /var/www/html/wordpress;
    index index.php index.html index.htm;

    access_log /var/log/nginx/wordpress_access.log;
    error_log /var/log/nginx/wordpress_error.log;

    location / {
        try_files $uri $uri/ /index.php?$is_args$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2)$ {
        expires max;
        log_not_found off;
    }

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt { log_not_found off; access_log off; }
}
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762545885628/0d793e79-efda-451b-9450-034b6096e379.jpeg align="center")

After define nginx config file create softlink and restart nginx service.

```plaintext
sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/

sudo ngninx -s reload

sudo nginx -t
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546046018/7189bdab-6f61-45df-842f-2ed83fc7b1cf.jpeg align="center")

Aftet define and restart nginx service. Bind your server ip with domain. I use cloudflare for domain. Define A record in dns record setting. After binding ip and domain you can check using nslookup command for actually domain is binding or not.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546209973/28a563b5-a043-4626-ba83-be3d94ffd3e1.jpeg align="center")

Now you can access your wordpress poral calling with domain name.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546314059/aca2ae92-c1df-44bc-90f2-5f7076b6c1cd.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546365930/fdaabb58-1f84-4daf-9959-4fdcb6f3a4b0.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546459394/75b530d5-320c-44c9-9abf-58c53301af64.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546501811/5d14aefb-917a-4a0a-8de1-71400c72d813.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546615123/c47d4900-33dc-4782-9eae-4c84c91ec780.jpeg align="center")

Even I’ve finished to setup wordpress settings my website can access only with http not https.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546631689/5c3bc33b-0d60-410b-994a-af4389185fb0.jpeg align="center")

So I setup Let’s encrypt certbot for https access. Install require packages. And run certbot.

```plaintext
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d your domain
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546655976/4c75b880-5fbc-460a-a74f-d1c45cb2becc.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546739807/051af9f8-c164-4f6a-9f64-c128f0c86636.jpeg align="center")

Now you can see my website can access via https vaild for 3 months.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546830167/ba36acf5-f376-4cf6-9709-a0a99901614e.jpeg align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1762546924397/7a17d3b2-0bbe-472e-bea0-af90eb8f590c.jpeg align="center")

Now you can see how to install and setup wordpress on AWS Lightsail with extra Let’s encrypt for SSL/TLS. After you test and run this scenario don’t forget to delete Lightsail. I don’t want to charges any extra cloud costs. Let me stop here and stay tune for another demo and lab. Happy learning. Thanks for giving me your time. If you enjoy and helpful this tutorial please like and share. I would really appreciate your support.
