Installing and Running your React App on Linux in 3 Minutes Flat

Installing and Running your React App on Linux in 3 Minutes Flat

This guide aims to facilitate the efficient deployment of a React application on a Linux operating system.

Prerequisite Installation:

The initial step necessitates the installation of essential tools on your Linux system. Open your terminal and execute the following command, substituting your_package_manager with the appropriate one for your distribution (e.g., apt, yum, dnf) and also having sudo privileges for logged in user.

In my case I'm going to use Ubuntu LinuxDistribution. Ubuntu use apt as it package manager.

curl -fsSL https://deb.nodesource.com/setup_21.x | sudo -E bash - &&
sudo apt-get install -y nodejs

Above command will install Node.js 21.x and its package manager, npm, which are fundamental components for running React applications.

Project Initialisation

Subsequently, we shall utilize a tool named create-react-app to establish your React application. Navigate to your desired project directory within the terminal and issue the following command:

npx create-react-app emeraldstech-react

Replace emeradstech-react with your preferred application name. This command will establish a new React project, encompassing all requisite configurations and dependencies.

Application Execution

To initiate your development server and commence the execution of your React application, navigate to your project directory using the cd command:

cd emeradstech-react

Finally, to launch the development server, execute the following command:

npm start

Upon successful execution, your React application will be operational and typically accessible at http://<server public ip>:3000 in your web browser.

To build the production ready artifacts run following command

npm run build

Above command will create an build directory by default and load the artifacts in it.

You can configure your Nginx or Apache web server to serve this react application

Installing and Configuring nginx you can find on https://blogs.emeraldstech.com/installing-and-configuring-nginx-on-linux-ubuntu-redhat-centos/

Read more