2017-06-19 67 views
-2

首次使用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找不到的錯誤。

請記住,這是我第一次,盡我所能,學習和提供足夠的信息,非常感謝。

回答

1

現在奇怪的(對我)的事情是,每當我去我的服務器的內部IP我立即登陸Site1。

這是正常現象。默認網站是首先定義的網站。如果您不通過服務器知道的主機名訪問該站點,則會獲得第一個。

我不能管理由internalIP /站點2

這是因爲/var/www/html/osticket/site2不存在訪問站點2。


您需要訪問的http://site2/代替http://192.168.1.123/site2/

使用虛擬主機名。您需要使用名稱。

(爲了舉例,我組成了一個IP地址)。

+0

非常感謝,我明白你在說什麼。但是現在我可以通過訪問support.intern訪問site1,但是我無法通過訪問site2.intern訪問site2。我在這裏錯過了什麼嗎? –

+0

@JaneMorning - 你說'ServerName site2'不是'ServerName site2.intern'。 – Quentin

+0

對不起,它不適用於兩者。我們在這裏使用.intern(在路由器中設置它),但site2.intern和site2都不工作。 –