我正在尝试在测试服务器上有两个带有Apache虚拟主机的单独站点。我将使用实例的IP地址(例如http://167.275.122.215)访问站点。当启用以下配置时,我将能够仅使用ip地址正确地加载第一个站点(使用http://167.275.122.215),而不是http://167.275.122.215/exp。当我指向该地址时出现404错误。我在这里做错了什么?
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
Alias /exp /usr/share/wordpress
DocumentRoot /usr/share/wordpress
<Directory /usr/share/wordpress>
Options FollowSymLinks
AllowOverride all
DirectoryIndex index.php
require all granted
</Directory>
</VirtualHost>
实际上,我需要能够在主站点仍然可用时(通过原始ip地址)通过相同的ip访问exp(实验)站点。我也尝试为实验站点提供其他端口(如下所示),但这仍然给我一个无法访问的站点错误。
<VirtualHost *:90>
<Directory /usr/share/wordpress>
Options FollowSymLinks
AllowOverride all
DirectoryIndex index.php
require all granted
</Directory>
</VirtualHost>
对于基于端口的多个站点,将默认端口列为第二个站点解决了该问题:
LISTEN 90
<VirtualHost *:90>
DocumentRoot /usr/share/wordpress
<Directory /usr/share/wordpress>
Options FollowSymLinks
AllowOverride all
DirectoryIndex index.php
require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/main
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>