0

I am facing issue to run the React application on CentOS server with Apache server. Can any one help me out to figure out this issue please.

Apache Config:

nano /etc/httpd/conf/httpd.conf

    <VirtualHost *:8081>
     ServerName localhost
      DocumentRoot /root/CC_CRM/client/dist
     <Directory "/root/CC_CRM/client/dist">

    Options -MultiViews
    RewriteEngine On
    # Don't rewrite files or directories
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ index.html [L]
    </Directory>
    </VirtualHost>

Getting Unable to connect issue on browser.

2
  • do you have your React app running? there is some steps that you need to do before having the app running through apache, is just HTML or do you have it served through normal HTML file? Commented Feb 5, 2020 at 9:56
  • @mamounothman I buidl my react app and given the dist folder path in <Directory> in Apache config. Commented Feb 5, 2020 at 10:39

1 Answer 1

1

Unable to connect error is thrown when you server is refused to connect that means your server isn't running or if it's running it might be running on different port instead of 80. To be sure you have to share you apache config file and after starting apache check for the LISTENING ports in CentOs To run app on another port

  1. Add additional ports in the /etc/apache2/ports.conf like so:

    Listen 80

    Listen 8888

Now in your VirtualHost file add that port like so:

<VirtualHost *:80 *:8888>
....other configs here
</VirtualHost>

Restart apache2:

sudo apache2ctl restart
Sign up to request clarification or add additional context in comments.

1 Comment

Yes you are correct. Apache running at 80 port so I Just trying to run the React application in different port. Kindly guide me to do that same process please.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.