首次使用Ubuntu 16.04 LTS Server设置Apache2服务器。我有一个网站的工作,我很满意。 现在我想在同一台服务器上创建一个网站2号,并通过internalIP/site1的和internalIP/SITE2访问它们第一次使用Apache,似乎无法设置两个站点
我创建了第二个站点的目录:/var/www/html/site2
和/etc/apache2/sites-available/
创建了一个名为001-default.conf
一个.conf文件,然后并且放入:
<VirtualHost *:80>
DocumentRoot "/var/www/html/site2/"
ServerName site2
</VirtualHost>
然后使用sudo a2ensite site2
来启用它。
在网站.conf文件/可我site1的是/etc/apache2/sites-available/000-default.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 [email protected]
ServerName support
ServerAlias support
DocumentRoot /var/www/html/osticket/
# 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>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
现在奇怪的(对我)的事情是,每当我去我的服务器我的内部IP立即着陆在Site1上。也许我改变了一些与此相关的配置,但我不记得......我知道我必须去InternalIP/osticket(site1的名称)才能访问它。我不能设法通过internalIP/site2或类似的东西访问site2。我收到一个404找不到的错误。
请记住,这是我第一次,尽我所能,学习和提供足够的信息,非常感谢。
非常感谢,我明白你在说什么。但是现在我可以通过访问support.intern访问site1,但是我无法通过访问site2.intern访问site2。我在这里错过了什么吗? –
@JaneMorning - 你说'ServerName site2'不是'ServerName site2.intern'。 – Quentin
对不起,它不适用于两者。我们在这里使用.intern(在路由器中设置它),但site2.intern和site2都不工作。 –