Skip to content

Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04

Netcloud24
Cloud Infrastructure Expert
HOSTING H1

Free web hosting H1

5 GB of storage and SSL for a small website or WordPress project.

Explore hosting H1
WINDOWS VPS + RDS

Run Windows applications remotely

Windows Server 2022 or 2025 and RDS CALs included in the plan. Choose resources and user capacity for your business.

Explore Windows VPS
NetCloud24 Expert Guides Open the dedicated video page

Video transcript: NetCloud24 Expert Guides. Practical knowledge for a reliable cloud. Cloud and VPS expertise, security, performance, and step-by-step tutorials. Learn, deploy, and keep building with NetCloud24.

 

 

Introduction

ReactJS is a popular JavaScript library for building user interfaces, especially for single-page applications. In this guide, you will learn how to install ReactJS and serve your application using Nginx on Ubuntu 22.04. This setup can be effectively hosted on a for optimal performance and scalability.

Prerequisites

  • An Ubuntu 22.04 server with root access
  • Node.js and npm (Node Package Manager) installed
  • Basic knowledge of Linux commands

Step 1: Update Your System

Start by updating your package index and upgrading existing packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and npm

Install Node.js and npm using the following commands:

sudo apt install nodejs npm -y

Verify the installation:

node -v
npm -v

Step 3: Create a React Application

Use the npx command to create a new React application. Replace my-app with your desired application name:

Visual overview of Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
Visual overview: Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
npx create-react-app my-app

Change into your application directory:

cd my-app

Step 4: Build the React Application

Build your React application for production:

npm run build

This command creates a build directory containing static files for deployment.

Step 5: Install Nginx

Install Nginx to serve your React application:

sudo apt install nginx -y

Step 6: Configure Nginx

Edit the Nginx configuration file to serve your React app:

sudo nano /etc/nginx/sites-available/default

Replace the existing content with the following:

Key topics covered in Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
Key topics covered in this NetCloud24 guide.
server {
    listen 80;
    server_name your_domain.com; # Replace with your domain or IP

    location / {
        root /path/to/my-app/build; # Adjust the path to your build directory
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }
}

Make sure to replace /path/to/my-app/build with the actual path to your React application’s build directory and your_domain.com with your domain or server IP address.

Step 7: Test Nginx Configuration

Test the Nginx configuration for syntax errors:

sudo nginx -t

Step 8: Restart Nginx

Restart Nginx to apply the changes:

sudo systemctl restart nginx

Step 9: Access Your React Application

Open your web browser and navigate to http://your_domain.com (or your server’s IP address). You should see your React application running.

Step 10: Conclusion

You have successfully installed ReactJS and configured Nginx to serve your application on Ubuntu 22.04. This setup provides a robust platform for web applications and can greatly benefit from being hosted on a . For additional options, explore various solutions, including Windows VPSVirtual Private Server Hosting and Windows VPS Hosting UK for optimal performance.

© 2024 ReactJS and Nginx Installation Tutorial. All rights reserved.

Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24

Comments are closed.

Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04

Netcloud24
Cloud Infrastructure Expert
HOSTING H1

Free web hosting H1

5 GB of storage and SSL for a small website or WordPress project.

Explore hosting H1
WINDOWS VPS + RDS

Run Windows applications remotely

Windows Server 2022 or 2025 and RDS CALs included in the plan. Choose resources and user capacity for your business.

Explore Windows VPS
NetCloud24 Expert Guides Open the dedicated video page

Video transcript: NetCloud24 Expert Guides. Practical knowledge for a reliable cloud. Cloud and VPS expertise, security, performance, and step-by-step tutorials. Learn, deploy, and keep building with NetCloud24.

 

 

Introduction

ReactJS is a popular JavaScript library for building user interfaces, especially for single-page applications. In this guide, you will learn how to install ReactJS and serve your application using Nginx on Ubuntu 22.04. This setup can be effectively hosted on a for optimal performance and scalability.

Prerequisites

  • An Ubuntu 22.04 server with root access
  • Node.js and npm (Node Package Manager) installed
  • Basic knowledge of Linux commands

Step 1: Update Your System

Start by updating your package index and upgrading existing packages:

sudo apt update && sudo apt upgrade -y

Step 2: Install Node.js and npm

Install Node.js and npm using the following commands:

sudo apt install nodejs npm -y

Verify the installation:

node -v
npm -v

Step 3: Create a React Application

Use the npx command to create a new React application. Replace my-app with your desired application name:

Visual overview of Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
Visual overview: Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
npx create-react-app my-app

Change into your application directory:

cd my-app

Step 4: Build the React Application

Build your React application for production:

npm run build

This command creates a build directory containing static files for deployment.

Step 5: Install Nginx

Install Nginx to serve your React application:

sudo apt install nginx -y

Step 6: Configure Nginx

Edit the Nginx configuration file to serve your React app:

sudo nano /etc/nginx/sites-available/default

Replace the existing content with the following:

Key topics covered in Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
Key topics covered in this NetCloud24 guide.
server {
    listen 80;
    server_name your_domain.com; # Replace with your domain or IP

    location / {
        root /path/to/my-app/build; # Adjust the path to your build directory
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }
}

Make sure to replace /path/to/my-app/build with the actual path to your React application’s build directory and your_domain.com with your domain or server IP address.

Step 7: Test Nginx Configuration

Test the Nginx configuration for syntax errors:

sudo nginx -t

Step 8: Restart Nginx

Restart Nginx to apply the changes:

sudo systemctl restart nginx

Step 9: Access Your React Application

Open your web browser and navigate to http://your_domain.com (or your server’s IP address). You should see your React application running.

Step 10: Conclusion

You have successfully installed ReactJS and configured Nginx to serve your application on Ubuntu 22.04. This setup provides a robust platform for web applications and can greatly benefit from being hosted on a . For additional options, explore various solutions, including Windows VPSVirtual Private Server Hosting and Windows VPS Hosting UK for optimal performance.

© 2024 ReactJS and Nginx Installation Tutorial. All rights reserved.

Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
Linux VPS & VPS Windows Setup Guide | NetCloud24 ReactJS with Nginx on Ubuntu 22.04
Explore more

More on this topic

Netcloud24
Netcloud24
Cloud Infrastructure Expert · NetCloud24

Comments are closed.