我有一个DO滴(Ubuntu 18.04),我想在其上托管两个站点。假设小滴的IP为101.1.1.1。现在,我希望从另一个服务器(具有不同的IP,假设104.1.1.1。)子域中指向这些站点。假设siteone.example.org和sitetwo.example.org。因此,我按照指南进行操作,并像这样设置Apache VirtualHost:
<VirtualHost *:80>
ServerAdmin webmaster@example.org
ServerName siteone.example.org
ServerAlias www.siteone.example.org
DocumentRoot /var/www/siteone/public_html
<Directory /var/www/siteone/public_html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
但是,当我在浏览器中按siteone.example.org时,没有任何响应。我在两个端点中都设置了一个名称,使其指向101.1.1.1。我在做错什么吗?
答案 0 :(得分:0)
您要在同一台计算机上有2个网站,每个网站都有一个IP地址吗?所以:
像这样:
Listen *.80
<VirtualHost 101.1.1.1:80>
ServerName siteone.example.org
ServerAlias www.siteone.example.org
ServerAdmin webmaster.example.org
DocumentRoot "/var/www/siteone/public/html"
<Directory /var/www/siteone/public_html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/siteone_error.log
CustomLog ${APACHE_LOG_DIR}/siteone_access.log combined
</VirtualHost>
<VirtualHost 104.1.1.1:80>
ServerName sitetwo.example.org
ServerAlias www.sitetwo.example.org
ServerAdmin webmaster.example.org
DocumentRoot "/var/www/sitetwo/public/html"
<Directory /var/www/sitetwo/public_html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/siteotwo_error.log
CustomLog ${APACHE_LOG_DIR}/sitetwo_access.log combined
</VirtualHost>
在您的DNS中,配置: