Answers:
您需要设置Apache VirtualHost。在Ubuntu中,这些位于/etc/apache2/sites-available/<my site>
在这种情况下,您的虚拟主机可能如下所示:
<VirtualHost *:80>
ServerName <myserver>
DocumentRoot /var/www # Point Apache to your web directory
<Directory />
Options -Indexes # Don't allow Apache to show a listing of the directory if someone navigates to http://myserver/
AllowOverride All # Allow .htaccess files in each site directory to be read
</Directory>
</VirtualHost>
这是最简单的设置,可以帮助您启动和运行。创建此虚拟主机文件后/etc/apache2/sites-available,运行sudo a2ensite <mysite>以启用该站点,然后重新启动apachesudo service apache2 restart
导航到http:// myserver /,您应该获得访问被拒绝页面,但导航到http:// myserver / site1,您应该看到正确的站点。