【问题标题】:React application not working in Apache server on CentOSReact 应用程序无法在 CentOS 上的 Apache 服务器中运行
【发布时间】:2020-02-05 09:37:47
【问题描述】:

我在使用 Apache 服务器在 CentOS 服务器上运行 React 应用程序时遇到问题。 谁能帮我解决这个问题。

Apache 配置:

纳米/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>

在浏览器上遇到Unable to connect 问题。

【问题讨论】:

  • 你的 React 应用运行了吗?在让应用程序通过 apache 运行之前,您需要执行一些步骤,只是 HTML 还是通过普通 HTML 文件提供服务?
  • @mamounothman 我构建了我的反应应用程序,并在 Apache 配置中的 中给出了 dist 文件夹路径。

标签: reactjs apache


【解决方案1】:

Unable to connect error 当你的服务器被拒绝连接时抛出,这意味着你的服务器没有运行,或者如果它正在运行,它可能在不同的端口而不是80 上运行。 为确保您必须分享您的 apache 配置文件,并在启动 apache 后检查 LISTENING 中的 LISTENING 端口CentOs 在另一个端口上运行应用程序

  1. /etc/apache2/ports.conf 中添加额外的端口,如下所示:

    听 80

    听8888

现在在您的 VirtualHost 文件中添加该端口,如下所示:

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

重启apache2:

sudo apache2ctl restart

【讨论】:

  • 是的,你是对的。 Apache 在 80 端口上运行,所以我只是想在不同的端口上运行 React 应用程序。请指导我做同样的过程。
猜你喜欢
  • 2021-12-08
  • 2018-08-13
  • 1970-01-01
  • 2017-07-21
  • 2021-11-28
  • 2016-12-21
  • 2018-04-16
  • 2016-12-09
  • 1970-01-01
相关资源
最近更新 更多