我正在尝试配置 apache,并在 /srv/www 中创建了一个目录,因为我希望我的默认根文件夹在那里而不是 /var/www。我在 /apache2/sites-available 中打开了配置文件(并将 sites-enabled 正确链接到此配置文件),它如下所示:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
serverAlias extracurricular.com
ServerAdmin [email protected]
DocumentRoot /srv/www/extracurricular.com
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks Mult
iViews
AllowOverride None
Order allow,deny
allow from all
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values are: debug, info, not ice, warn, error, crit, alert, emerg
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/extracurricular.com_access.log combined
</VirtualHost>
我的 vps 的 IP 是:http://192.99.246.96/
它只是将我带到 /var/www 文件夹,而不是 /srv/www/extracurricular.com(我的域名)。这是为什么?
PS 我的 /extracurricular.com 目录中有一个简单的 index.html
答案1
<VirtualHost *:80>
ServerName extracurricular.com
#serverAlias www.extracurricular.com
ServerAdmin [email protected]
DocumentRoot /srv/www/extracurricular.com
<Directory "/srv/www/extracurricular.com">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
DirectoryIndex index.php index.html index.htm
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values are: debug, info, not ice, warn, error, crit, alert, emerg
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/extracurricular.com_access.log combined
</VirtualHost>