[英]how to host multiple virtual hosts from same IP address in Apache server over AWS?
I want to host two different angular panels over Apache (AWS).我想在 Apache (AWS) 上托管两个不同的 angular 面板。 So I disabled the default 000-default.conf
file in etc/apache2/sites-available
using a2dissite 000-default.conf
and made two files webAdmin.conf
and webUIpanel.conf
.因此,我使用a2dissite 000-default.conf
禁用了etc/apache2/sites-available
中的默认000-default.conf
文件,并制作了两个文件webAdmin.conf
和webUIpanel.conf
。 Now my webAdmin.conf
has the following configuration现在我的webAdmin.conf
有以下配置
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/AngularProjects/getItHomeNow_UI/dist
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and webUIpanel.conf
has following和webUIpanel.conf
有以下
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/AngularProjects/getItHomeNow_UserPanel/dist
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Then I used a2ensite
to enable both config files and at last sudo systemctl restart apache2
.然后我使用a2ensite
来启用这两个配置文件,最后sudo systemctl restart apache2
。 But one of them working at a time.但他们中的一个同时工作。 I need to disable one to make other work.我需要禁用一个才能使其他工作。 Kindly suggest me where did I go wrong?请建议我 go 哪里错了?
You should add ServerName
in your VirtualHost
config so Apache can decide which site should get the request.您应该在VirtualHost
配置中添加ServerName
,以便 Apache 可以决定哪个站点应该收到请求。 So to apply that to your config it should look like:因此,要将其应用于您的配置,它应该如下所示:
webAdmin.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/AngularProjects/getItHomeNow_UI/dist
ServerName www.example1.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
and webUIpanel.conf
has following和webUIpanel.conf
有以下
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/AngularProjects/getItHomeNow_UserPanel/dist
ServerName www.example2.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
NOTE: Both ServerName
should be valid domains so they resolve to your server or use your /etc/hosts
file to point them to your server IP.注意:两个ServerName
都应该是有效的域,以便它们解析到您的服务器或使用您的/etc/hosts
文件将它们指向您的服务器 IP。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.