---
title: "Migrate a WordPress to AWS EC2 Ubuntu Server 24.04 - Seahawk"
description: "Learn how to migrate a WordPress website to AWS EC2 Ubuntu 24.04 with SCP and Nginx in this complete step-by-step tutorial. SEO-friendly and beginner-ready."
url: https://seahawkmedia.com/hosting/migrate-wordpress-to-aws-ec2-ubuntu-24-04/
language: en
---

[Home](https://seahawkmedia.com/) / [Hosting](https://seahawkmedia.com/hosting/) /How to Set Up or Migrate a WordPress Website to AWS EC2 Ubuntu Server 24.04

Guide

# How to Set Up or Migrate a WordPress Website to AWS EC2 Ubuntu Server 24.04

![Blaise Kavai](https://seahawkmedia.com/team/blaise-kavai.webp) By [Blaise Kavai](https://seahawkmedia.com/author/blaise-kavai/) Reviewed by the [Seahawk editorial team](https://seahawkmedia.com/editorial-standards/) Updated February 3, 2026

Published July 4, 2025 7 min read

[WordPress](https://seahawkmedia.com/wordpress/) [For businesses](https://seahawkmedia.com/small-business/)

Also in [Dansk](https://seahawkmedia.com/da/hosting/migrer-wordpress-til-aws-ec2-ubuntu-24-04/) [Deutsch](https://seahawkmedia.com/de/hosting/wordpress-auf-aws-ec2-ubuntu-24.04-migrieren/) [Español](https://seahawkmedia.com/es/hospedaje/migrar-wordpress-a-aws-ec2-ubuntu-24-04/) [Français](https://seahawkmedia.com/fr/hebergement/migration-de-wordpress-vers-aws-ec2-ubuntu-24.04/) [Italiano](https://seahawkmedia.com/it/hosting/migrare-wordpress-su-aws-ec2-ubuntu-24.04/) [日本語](https://seahawkmedia.com/ja/%E3%83%9B%E3%82%B9%E3%83%86%E3%82%A3%E3%83%B3%E3%82%B0/wordpress%E3%82%92aws-ec2-ubuntu-24.04%E3%81%AB%E7%A7%BB%E8%A1%8C%E3%81%99%E3%82%8B/) [한국어](https://seahawkmedia.com/ko/%ED%98%B8%EC%8A%A4%ED%8C%85/%EC%9B%8C%EB%93%9C%ED%94%84%EB%A0%88%EC%8A%A4%EB%A5%BC-aws-ec2-%EC%9A%B0%EB%B6%84%ED%88%AC-24.04%EB%A1%9C-%EB%A7%88%EC%9D%B4%EA%B7%B8%EB%A0%88%EC%9D%B4%EC%85%98/) [Nederlands](https://seahawkmedia.com/nl/hosting/wordpress-migreren-naar-aws-ec2-ubuntu-24-04/) [Português](https://seahawkmedia.com/pt/hospedagem/migrar-wordpress-para-aws-ec2-ubuntu-24-04/) [Svenska](https://seahawkmedia.com/sv/hosting/migrera-wordpress-till-aws-ec2-ubuntu-24-04/)

Running a WordPress website on AWS EC2 gives you full control over your hosting environment. When combined with [Ubuntu 24.04](https://ubuntu.com/blog/tag/ubuntu-24-04-lts), it creates a reliable and scalable setup that can handle everything from small blogs to high-traffic business websites.

If you are just getting started, setting up WordPress on a new EC2 instance is one of the most efficient ways to create a custom hosting solution. For those who already have a website, migrating your WordPress site from an older host or server ensures better performance, improved security, and more flexibility in the long run.

This guide walks you through both approaches. First, you will learn how to launch a brand-new WordPress site from scratch. Then, we will cover how to safely migrate an existing WordPress website to a new AWS EC2 instance running Ubuntu 24.04.

## Prerequisites: Migrate a WordPress Website to AWS EC2 Ubuntu Server 24.04

Before you begin setting up or [migrating your WordPress website](https://seahawkmedia.com/services/wordpress-migration-services/) to AWS EC2 with Ubuntu 24.04, make sure you have everything you need in place. This will help you follow the steps smoothly and avoid delays during the process.

Here is what you should have ready:

- An active AWS account with access to the EC2 service

- A secure key pair to connect to your server using SSH

- Basic knowledge of the Linux command line

- A domain name (optional but helpful for testing and SSL setup)

- A complete backup of your existing WordPress site if you plan to migrate

- A stable internet connection for transferring files between servers

Once these items are ready, you can move forward confidently with either the new setup or the migration process.

#### Need Help Migrating Your WordPress Website to AWS?

We handle secure WordPress migrations with zero downtime, optimized server configurations, and complete peace of mind.

- [Explore Our WordPress Migration Services](https://seahawkmedia.com/services/wordpress-migration-services/)

## Set Up WordPress from Scratch with LAMP Stack on Ubuntu 24.04

If you are starting fresh, installing WordPress on an AWS EC2 instance with the LAMP stack is one of the most straightforward ways to get your website online. The LAMP stack includes Linux, Apache, MySQL, and PHP, which together provide a stable environment for WordPress.

### Step 1: Launch a New EC2 Instance

Log in to your AWS Management Console and go to the EC2 Dashboard. Click on the Launch Instance button.

Choose the Ubuntu Server 24.04 LTS as your machine image. Select an instance type based on your needs. For small projects, the t2.micro instance is suitable and eligible for the AWS Free Tier.

During configuration, enable auto-assign public IP and create a new key pair if you do not already have one. Allow SSH, HTTP, and HTTPS in the security group rules. Finally, launch the instance and note its public IP address.

### Step 2: Connect to the Server via SSH

Open your terminal or SSH client. Use the command below to connect, replacing the placeholders with your actual key file path and EC2 public IP.

```bash
ssh -i /path/to/your-key.pem ubuntu@your-ec2-ip
```

Make sure your key file has the correct permissions. If needed, run this command before connecting:

```bash
chmod 400 your-key.pem
```

### Step 3: Update and Install Apache Web Server

Once logged in, update the server and install Apache with the following commands:

```bash
sudo apt update
sudo apt install apache2 -y
```

After installation, make sure Apache is running:

```bash
sudo systemctl enable apache2
sudo systemctl start apache2
```

Visit your EC2 public IP address in a browser. If Apache is running, you will see the default Ubuntu web page.

### Step 4: Install MySQL and Create the WordPress Database

Install MySQL Server:

```bash
sudo apt install mysql-server -y
```

Secure the MySQL installation by running:

```bash
sudo mysql_secure_installation
```

Next, log in to MySQL to create the database and user for WordPress:

```bash
sudo mysql
```

Inside the MySQL prompt, run:

```
CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```

### Step 5: Install PHP and Required Extensions

WordPress needs PHP to run, along with several extensions. Install everything using:

```bash
sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml 
```

You can confirm the PHP version installed by running:

```
php -v
```

Restart Apache to load the PHP module:

```bash
sudo systemctl restart apache2
```

### Step 6: Download and Configure WordPress

Go to your temporary directory and download WordPress:

```bash
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
```

Create the configuration file:

```bash
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
```

Copy the WordPress files to the web root:

```bash
sudo cp -a /tmp/wordpress/. /var/www/html
```

Set the proper permissions:

```bash
sudo chown -R www-data:www-data /var/www/html
sudo find /var/www/html -type d -exec chmod 750 {} \;
sudo find /var/www/html -type f -exec chmod 640 {} \;
```

### Step 7: Configure Apache Virtual Host

Create a new Apache configuration file for your site:

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

Paste the following configuration:

```
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    <Directory /var/www/html/>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```

Enable the site and necessary modules:

```bash
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo a2dissite 000-default.conf
sudo apache2ctl configtest
sudo systemctl restart apache2
```

### Step 8: Complete the WordPress Installation

Open your browser and visit your EC2 public IP or domain name. You should see the WordPress setup screen.

Choose your language, site title, admin username, and password. Enter your email address and decide whether to discourage search engines.

Once you click Install WordPress, you will be taken to the login page. Use the credentials you just created to log in and start customizing your website.

## Migrate an Existing WordPress Site to AWS EC2 with Nginx and SCP

If you already have a WordPress website running on another server, you can move it to a new EC2 instance using a secure and efficient method. This part of the guide shows you how to migrate your files and database using SCP and configure Nginx on your Ubuntu 24.04 server.

### Step 1: Prepare Your New EC2 Instance

Start by launching a new EC2 instance with Ubuntu 24.04, just like you would for a fresh setup. Once the server is up, install the following packages:

```bash
sudo apt update
sudo apt install nginx mysql-server php-fpm php-mysql -y
```

Enable and start the services:

```bash
sudo systemctl enable nginx mysql php8.1-fpm
sudo systemctl start nginx mysql php8.1-fpm
```

### Step 2: Set Up SSH Access Between Servers

To copy files directly between servers, you need to establish a secure connection.

On your new EC2 instance, generate a new SSH key:

```bash
ssh-keygen -t ed25519 -C "wordpress_migration"
```

Display your public key:

```bash
cat ~/.ssh/id_ed25519.pub
```

Now, log in to your old server and add this key to its authorized keys file:

```bash
nano ~/.ssh/authorized_keys
```

Paste the key and save. This allows the new server to connect securely.

### Step 3: Transfer Website Files Using SCP

Back on your EC2 server, copy the WordPress files from the old server:

```bash
scp -r user@oldserver:/var/www/html /home/ubuntu/html_backup
```

Move the files into place and adjust permissions:

```bash
sudo mv /home/ubuntu/html_backup /var/www/yourdomain.com
sudo chown -R www-data:www-data /var/www/yourdomain.com
```

### Step 4: Create MySQL Database and Import the Data

On your EC2 server, log into MySQL:

```bash
sudo mysql
```

Create a database and user:

```
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_520_ci;
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```

Export the database from the old server:

```bash
mysqldump -u db_user -p db_name > export.sql
```

Transfer it to the EC2 instance:

```bash
scp export.sql ubuntu@ec2-ip:/home/ubuntu/
```

Import it into the new database:

```bash
mysql -u wordpressuser -p wordpress < /home/ubuntu/export.sql
```

### Step 5: Configure Nginx for the Migrated Site

Create a new Nginx configuration file:

```bash
sudo nano /etc/nginx/sites-available/yourdomain.com
```

Add the following configuration:

```
server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;

    root /var/www/yourdomain.com;
    index index.php index.html index.htm;

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

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}
```

Enable the site and reload Nginx:

```bash
sudo ln -s /etc/nginx/sites-available/yourdomain.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
```

### Step 6: Test the Site with Local DNS

Before updating the DNS for the world, you can test your new server using your local machine. Edit your `hosts` file:

On Mac or Linux:

```bash
sudo nano /etc/hosts
```

Add the following line:

```
EC2_PUBLIC_IP yourdomain.com
```

Now, when you open your site in a browser, it will load from the new EC2 server, while visitors will still see the live site from the old server.

### Step 7: Set Up SSL with Let’s Encrypt

Once DNS is switched and your domain points to the new EC2 server, install Certbot to enable HTTPS:

```bash
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com
```

Certbot will configure SSL and renew certificates automatically.

### Step 8: Final Database Sync and DNS Switch

To avoid losing any recent data, perform one final database export and import before switching DNS.

On the old server, export the database again:

```bash
mysqldump -u db_user -p db_name > latest.sql
```

Transfer it to the EC2 server:

```bash
scp latest.sql ubuntu@ec2-ip:/home/ubuntu/
```

Import it:

```bash
mysql -u wordpressuser -p wordpress < /home/ubuntu/latest.sql
```

Now update your DNS A record to point to your EC2 instance’s public IP. DNS changes can take a few minutes to a few hours to propagate.

## Conclusion: Launch, Migrate, and Grow with AWS EC2

Setting up or migrating a WordPress website to AWS EC2 with Ubuntu 24.04 gives you greater control, stronger performance, and room to grow. Whether you chose the LAMP-based fresh installation or migrated from an old server using Nginx and SCP, you now have a powerful setup ready to support your site’s future.

With your WordPress site running on EC2, you benefit from flexible scaling, fast response times, and full ownership of your server environment. As traffic grows or requirements change, you can upgrade your instance type, set up automatic backups, or even connect with additional AWS services like CloudFront or Route 53.

Remember to keep your server updated, monitor performance regularly, and renew your SSL certificates when needed. With this foundation in place, you are ready to build a secure and professional online presence that can handle whatever comes next.

HostList

## The hosting directory with no paid rankings.

Compare 30,000+ web hosts and MSPs across 120+ countries, ranked by HRI, an independent 0 to 100 rating built from verified data. Find your perfect web host.

[Go to HostList](https://hostlist.io/) [Free homepage rebuild](https://seahawkmedia.com/free-homepage-rebuild/)

More in Hosting

[GreenGeeks Vs GoDaddy: A Detailed Comparison June 16, 2025 · 8 min read](https://seahawkmedia.com/hosting/greengeeks-vs-godaddy-which-one-to-opt/) [Apache vs Nginx: What’s Better for Hosting WordPress in 2025? June 4, 2025 · 9 min read](https://seahawkmedia.com/hosting/apache-vs-nginx/) [How to Resell WordPress Hosting: The Ultimate Guide July 5, 2025 · 17 min read](https://seahawkmedia.com/hosting/how-to-resell-wordpress-hosting/) [How to Open WordPress Site by IP Instead of Domain Name July 5, 2025 · 7 min read](https://seahawkmedia.com/hosting/open-wordpress-site-by-ip/)
