在AWS上为各种Web应用程序设置vhost

时间:2018-05-14 06:32:45

标签: angularjs apache amazon-web-services vhosts

在我的AWS实例上,我有以下设置

/var/www/html/admin <--- angularjs application
/var/www/html/api <--- angularjs application
/var/www/html/main <--- django application

如何使它们全部可以访问&#34;个别网站&#34;?例如,浏览到:

http://ec2-xx-xx-xxx-xxx.eu-west-2.compute.amazonaws.com/admin
http://ec2-xx-xx-xxx-xxx.eu-west-2.compute.amazonaws.com/api
http://ec2-xx-xx-xxx-xxx.eu-west-2.compute.amazonaws.com/main

每个人都应该去一个自给自足的网站。

现在转到http://ec2-xx-xx-xxx-xxx.eu-west-2.compute.amazonaws.com/main(例如AngularJS应用程序),我看到这样的错误:

Failed to load resource: the server responded with a status of 404 (Not Found)

我登录了该站点,发现它认为资产位于上面的目录中,而不是&#34; main&#34;子目录。我可以理解我需要以某种方式设置vhost ...这些在AWS实例上的位置是什么?它们看起来像这样吗?

<VirtualHost *:80>
    ServerAdmin info@main.com
    ServerName main.com
    ServerAlias www.main.com
    DocumentRoot /var/www/html/main

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

<VirtualHost *:80>
    ServerAdmin info@main.com
    ServerName main.com/api
    ServerAlias www.main.com/api
    DocumentRoot /var/www/html/api

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

<VirtualHost *:80>
    ServerAdmin info@main.com
    ServerName main.com/admin
    ServerAlias www.main.com/admin
    DocumentRoot /var/www/html/admin

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

0 个答案:

没有答案