首次使用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都不工作。 –