![](/img/trans.png)
[英]Apache multiple VirtualHost with same ServerName, same IP and Port but different DocumentRoot, possible?
[英]Apache virtualhost servername by ip + documentroot
我试图让这个虚拟主机在apache + ubuntu上工作。 我希望它在没有真实域名的情况下只能通过ip和路径来工作。 现在没有被激活。 可以像这样使用serverName还是仅域名有效?
<VirtualHost *:80>
serverName 37.35.66.98/just-do-it/
DocumentRoot /var/www/html/just-do-it/web
<Directory /var/www/html/just-do-it/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
从服务器名称中删除路径部分,然后就可以了
<VirtualHost *:80>
serverName 37.35.66.98
DocumentRoot /var/www/html/just-do-it/web
<Directory /var/www/html/just-do-it/web>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
不要忘记在/etc/hosts
文件中添加服务器名称
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.