• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.

Question How to deploy React app?

sernuxo

New Pleskian
Server operating system version
CentOS Linux 7.9.2009
Plesk version and microupdate number
18.0.61
Hello Plesk Support Community,

I am currently facing challenges in deploying a React project on Plesk. I have seen multiple methods mentioned for deploying React apps, such as copying build files to httpdocs or setting up a Node.js environment directly in Plesk, but I am unclear on the best practices for this environment and how to handle Node.js updates within Plesk.

Could anyone guide me on the following:

1. What is the recommended method for deploying a React application in Plesk? Should I place the build files in the httpdocs directory, or is there a preferred method involving Node.js setups?

2. How can I update Node.js in Plesk to version 18 or higher? I need guidance on updating Node.js on a Plesk server as the default version does not meet my project’s requirements.

3. Current Environment: I am hosting a PrestaShop on my main domain and now I am experimenting with the React project on a subdomain (test.example.com). The idea is to switch that prestashop for the new website done in react

Any step-by-step instructions, links to relevant guides, or personal insights would be greatly appreciated as I navigate these challenges.

Thank you very much for your assistance.
 
Hi Aleksei!

No I don't have any backend, maybe in a future I try to add, but right now my current goal is to deploy the React project without any backend for the time being
 
Thank you for the guidance. I would like to ask if I can place the content of the build folder in a subdomain to test it first. Also, if I do this, would it interfere with or disrupt my current website, which is built with PrestaShop and hosted on the main domain?


Thank you for your assistance.
 
Thank you for your previous guidance. Just to confirm, I will place the content of the dist folder (which is the build folder for my React project) directly into the document root of my subdomain (httpdocs of test.joma-tools.com), without including the dist folder itself.

Is this the correct approach?

Thank you for your assistance.
 

Attachments

  • Captura de pantalla 2024-07-19 a las 13.23.29.png
    Captura de pantalla 2024-07-19 a las 13.23.29.png
    155.2 KB · Views: 6
I have also configured the rewrite rules in the .htaccess file to handle client-side routing.

However, when I try to access the website at xxxxx.com, I receive the following error: ERR_ADDRESS_UNREACHABLE.

Is there something I might be missing in the configuration?

Thank you for your assistance.
 
The ERR_ADDRESS_UNREACHABLE error usually indicates an browser cache issue. Have you tried an other browser?
 
Could you please confirm if there are any additional configurations needed once the files are in the httpdocs folder? For example:

1. Is there any specific setting in Plesk to point to these files or make sure they are served correctly?

2. Do I need to perform any installation steps or ensure a specific Node.js version is available on the server to run the project, even though it’s a static build?

3. Any other settings or steps that might be required to ensure the React app runs correctly?

Thank you for the assistance!
 
1. Is there any specific setting in Plesk to point to these files or make sure they are served correctly?
no, any file inside of the document root can be served, for instance, you can put the test.txt file and it will be available on example.com/test.txt
2. Do I need to perform any installation steps or ensure a specific Node.js version is available on the server to run the project, even though it’s a static build?
node.js no need because you upload the compiled application with all prepared files (js, CSS, HTML)
3. Any other settings or steps that might be required to ensure the React app runs correctly?
no, a React app is just a bunch of HTML, JS and CSS files so it should just work
 
Hello!


I have decided to abandon the subdomain approach and created a new test domain .plesk. I followed the instructions provided, and it worked; I can now see the page correctly.

Now, if I want to move these files to the main domain, which currently has a PrestaShop website, what will happen to the PrestaShop content? Is there any guide or recommendation for this type of migration?

Thank you for your assistance.
 
It's hard to say because I don't know how a PrestaShop website was implemented but I think you can rename the websites. In this case, you can always restore the old website.
 
Back
Top