嗨,我到了指向一个服务器IP的域名。服务器是运行Ubuntu和Apache2的VPS服务器。
现在我正在尝试使用Virtualhost托管两个不同的站点。
以下是我尝试设置虚拟主机的步骤:
root@vps520749:~# sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/ root@vps520749:~# sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/levsite.nl.conf
root@vps520749:~# sudo nano /etc/apache2/sites-available/levsite.nl.conf
root@vps520749:~# sudo cp /etc/apache2/sites-available/levsite.nl.conf /etc/apache2/sites-available/informaticaproject.nl.conf
root@vps520749:~# sudo nano /etc/apache2/sites-available/informaticaproject.nl.conf
root@vps520749:~# sudo a2ensite levsite.nl.conf
Enabling site levsite.nl.
To activate the new configuration, you need to run:
service apache2 reload
root@vps520749:~# sudo a2ensite informaticaproject.nl.conf
Enabling site informaticaproject.nl.
To activate the new configuration, you need to run:
service apache2 reload
root@vps520749:~# sudo a2dissite 000-default.conf
Site 000-default disabled.
To activate the new configuration, you need to run:
service apache2 reload
root@vps520749:~# sudo systemctl restart apache2
root@vps520749:~# sudo service apache2 restart
root@vps520749:~# sudo service apache2 reload
root@vps520749:~# sudo nano /etc/apache2/sites-available/informaticaproject.nl.conf
root@vps520749:~# sudo a2ensite informaticaproject.nl.conf
Site informaticaproject.nl already enabled
root@vps520749:~# sudo a2ensite levsite.nl.conf
Site levsite.nl already enabled
root@vps520749:~# sudo nano /etc/apache2/sites-available/levsite.nl.conf
root@vps520749:~# sudo a2dissite 000-default.conf
Site 000-default already disabled
这是levsite.nl.conf:
<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.
#ServerName www.example.com
ServerAdmin admin@levsite.nl
ServerName levsite.nl
ServerAlias www.levsite.nl
DocumentRoot /var/www/levsite.nl/public_html
# 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
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
informaticaproject.nl.conf:
<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.
#ServerName www.example.com
ServerAdmin admin@informaticaproject.nl
ServerName informaticaproject.nl
ServerAlias www.informaticaproject.nl
DocumentRoot /var/www/informaticaproject.nl/public_html
# 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
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
但它仍然无效,我使用levsite.nl
访问服务器或informaticaproject.nl
访问服务器我总是指向/var/www/informaticaproject.nl/public_html
....
我在这里缺少什么?