我不明白为什么 URL hello.apoio.co 解析为 var/www/ 文件夹而不是 var/www/hello.apoio.co 文件夹
我确信这很简单,但我看不出来?我严格按照官方说明操作。如能提供任何帮助,我将不胜感激
以下是虚拟主机文件中的代码
DocumentRoot /var/www/hello.apoio.co/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/hello.apoio.co/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
答案1
虚拟主机文件显示 Apache2 必须可访问的某些目录的路径。
我假设您想通过http://hello.apoio.co
在浏览器中输入来访问此目录,如果是这种情况,那么它应该是ServerName
虚拟主机文件内的指令。
所以你发布的文件必须变成:
<VirtualHost *:80>
ServerName hello.apoio.co
ServerAlias www.hello.apoio.co
DocumentRoot /var/www/hello.apoio.co/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/hello.apoio.co/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
在上面的虚拟主机配置中ServerName和ServerAlias用于设置相应的URL及其别名。
更多信息使用基于名称的虚拟主机