18th June 2024

Let’s look into the setup to deploy React app on cPanel. Bobcares, as part of our cPanel & WHM Help Services presents options to each question that comes our manner.

Setup to Deploy Reactjs App on cPanel

We should run the next steps to be able to arrange React.js app on cPanel:

1. Initially, open the terminal or command immediate.

2. Go to the listing the place we wish to create the React app.

cpanel deploy react app

3. Run the subsequent code:

npx create-react-app your-app-name.

4. Go to the React app’s root listing.

5. Open package deal.json in a textual content editor.

6. Add the “homepage” attribute with the area identify:

"homepage": "http://your_domain_name.com"

7. Now, go to the foundation listing of the React app.

8. Set up dependencies:

i. Utilizing Yarn: yarn set up

ii. Utilizing npm: npm set up

9. Construct the app:

i. Utilizing Yarn: yarn construct

ii. Utilizing npm: npm run construct

10. Go to the general public folder within the React app.

11. Create a brand new file named .htaccess.

12. Insert the next content material:

RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]

13. Now, to deploy the app on cPanel, log into the cPanel account.

14. Navigate to “File Supervisor” within the cPanel dashboard.

15. Go to the public_html listing.

16. Add the construct listing from the React app.

17. Save the uploaded information.

[Looking for a solution to another query? We are just a click away.]

Conclusion

The article presents the steps from our Tech crew to arrange React app on cPanel.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.