Bessa Community Apps | React Native App Developer

Setting Up Your EC2 Instance for Next.js Hosting

A step-by-step setup guide for any app developer ready to deploy a Next.js project on AWS EC2

For any React Native app developer expanding into full-stack and web solutions, deploying a Next.js app on AWS EC2 is a power move. This setup combines the flexibility of cloud infrastructure with the performance of server-side rendering, ideal for businesses needing scalable, cross-platform app development. Whether you’re managing custom business app solutions or an enterprise-grade product, learning to host Next.js on EC2 builds confidence in creating seamless digital ecosystems that connect your mobile app development with robust, production-ready web experiences.

Be sure to use the desired region.

Create an SSH key pair and upload it to AWS before generating an EC2 instance. Use this key when setting up your EC2.

Install and Configure Apache

sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
sudo a2enmod proxy_http
sudo systemctl restart apache2

Modify files in /etc/apache2/sites-available accordingly and enable and restart, if necessary:

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/<domain>.conf
sudo rm -R /var/www/html

Example File:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName <domain>
    ServerAlias <subdomain>.<domain>
    DocumentRoot /var/www/<project>
...
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
</VirtualHost>
sudo a2dissite 000-default
sudo a2ensite <domain>
sudo systemctl reload apache2

Generate an SSL Certificate

Make sure to add the elastic IP address to the DNS records so the app resolves before completing the next steps.

sudo apt-get install certbot python3-certbot-apache
sudo certbot --apache

Install Node and NPM

sudo apt install nodejs
sudo apt install npm

Install PM2

sudo npm install pm2 -g 

Clone Project

ssh-keygen

Add your public key to GitLab through the Console.

sudo chown -R $USER /var/www
git clone [email protected]:<something>/<something>.git
git fetch
git checkout <branch>
git pull

Start App

Add your variables with:

sudo nano .env

Inside the project run

npm install
npm run build
pm2 start npm --name <project> -- run start -- -p 3000

Gotchas

Cloning your Project

Do not use sudo when cloning your project.

Make Changes

Pull, install, and:

pm2 restart <project>

Deploying a Next.js app on AWS EC2 gives you a solid foundation for growth, from performance-driven websites to cross-platform apps that feel polished, fast, and dependable. For any React Native app developer, understanding how your web and mobile layers connect is what transforms good code into great user experiences. With custom app development and ongoing support in mind, this workflow keeps your projects secure, scalable, and ready to meet enterprise demands without losing the creative edge your users love.

If you’re ready to bring your Next.js, Expo, or React Native project to life, or need expert guidance deploying your app on AWS, let’s talk. As a React Native app developer and mobile software engineer, I help startups and organizations build, launch, and scale cross-platform apps that perform beautifully across iOS, Android, and the web. Reach out today!

Start with a Free Discovery Session

Every project begins with a conversation—no pressure, no commitment. At Bessa Apps, I offer a free Discovery phase designed to uncover your goals, explore your vision, and pitch tailored solutions that fit. As a react native app developer, I believe the best partnerships start with listening, not selling. Whether you're dreaming up a sleek iOS and Android app or planning a custom web development project, this first step helps us identify the opportunities that matter most to your business and your customers.

Think of Discovery as your launchpad. It's where strategy meets possibility, giving you clarity and direction before any code is written. From refining your concept to mapping out features like in-app purchases, direct messaging, or authentication, I'll guide you through the options with transparency and expertise. The result will be a clear path forward, backed by app development services that balance innovation with practicality, so you can move toward launch with confidence.

topher

@

bessaapps.com

© Copyright Bessa Community Apps, LLC

Setting Up Your EC2 Instance for Next.js Hosting | Bessa Community Apps | React Native App Developer