我正在尝试将虚拟主机设置为使用Apache 2.4监听不同的端口
在端口80上:纯HTML页面。 在端口81上:一个Angular6应用。
在我的0_web.conf
<VirtualHost *:80>
ServerName web
DocumentRoot /var/www/html/web
DirectoryIndex index.html
<Directory /var/www/html/web>
AllowOverride all
</Directory>
</VirtualHost>
在front.conf
Listen 81
<VirtualHost *:81>
ServerName munitdp
<Directory /var/www/dist/>
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html
# to allow html5 state links
RewriteRule ^ index.html [L]
</Directory>
</VirtualHost>
我正在使用Amazon EC2服务器。目前,我没有任何域,因此我访问的网址为http://ec2-18-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/
apachectl -S的输出
VirtualHost configuration:
*:80 web (/etc/httpd/conf.d/0_web.conf:1)
*:81 munitdp (/etc/httpd/conf.d/front.conf:2)
ServerRoot: "/etc/httpd"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/etc/httpd/logs/error_log"
Mutex proxy: using_defaults
Mutex authn-socache: using_defaults
Mutex default: dir="/run/httpd/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex cache-socache: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex proxy-balancer-shm: using_defaults
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex lua-ivm-shm: using_defaults
PidFile: "/run/httpd/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="apache" id=48
Group: name="apache" id=48
当我输入http://ec2-18-xxx-xxx-xxx.us-west-2.compute.amazonaws.com/时,我会进入html页面,但是访问http://ec2-18-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:81会使我进入“ /的索引”,列出了web/。
有什么想法吗?我在这里撞墙。
答案 0 :(得分:0)
我看不到第二个vHost中定义的DocumentRoot。也许添加
DocumentRoot /var/www/dist/
到您的front.conf