使用 angular 应用程序配置 apache 虚拟主机

Configure apache virtual host with angular app

我 运行 陷入困境,我的网站主页将只显示 "index of/" 页面而不是我的 angular 应用程序,甚至只是一个 index.html。我不确定是什么原因造成的,因为 vhost 配置与同一服务器上的其他三个网站 运行 几乎完全相同。 Apache 已重新启动,然后它停止为 angular 应用提供服务。

配置:

<VirtualHost *:80>

    ServerName website.com
    ServerAlias www.website.com
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/website.com/dist

    <Directory /var/www/html/website.com/dist>
        <Files ~ (\.cgi$)>
            SetHandler cgi-script
            Options ExecCGI
            allow from all
        </Files>
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

自从我最初设置它以来已经有一段时间了,并且最近进行了许多更改试图让它再次工作我主要有一些愚蠢的混乱我忽略了。感谢任何提示或建议!

这是因为有一个默认的 v-host 文件覆盖了我需要的配置。通过删除默认文件 000-default.conf,所需的较新文件将加载到 Apache 并为网站提供服务而不会出现问题。

对于遇到此类问题的其他人,请仔细检查是否有默认或重复的配置覆盖您需要使用的配置。请参阅@JoelJoseph 的评论以获取有见地的文章和有关发布 Angular 6+ 应用程序的更多信息。