2016-07-23 126 views
0

我從Fedora移到了Ubuntu 16.04。如何在一個文件中設置多個虛擬主機

在fedora我可以在一個文件中列出無盡的虛擬主機。在Ubuntu中,我必須爲每個虛擬主機創建一個新文件。我已經有了所有虛擬主機的列表。是在Ubuntu的任何方式來做到這一點?

# Virtual Hosts 
# 
# Required modules: mod_log_config 

# If you want to maintain multiple domains/hostnames on your 
# machine you can setup VirtualHost containers for them. Most configurations 
# use only name-based virtual hosts so the server doesn't need to worry about 
# IP addresses. This is indicated by the asterisks in the directives below. 
# 
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/> 
# for further details before you try to setup virtual hosts. 
# 
# You may use the command line option '-S' to verify your virtual host 
# configuration. 

# 
# VirtualHost example: 
# Almost any Apache directive may go into a VirtualHost container. 
# The first VirtualHost section is used for all requests that do not 
# match a ServerName or ServerAlias in any <VirtualHost> block. 
# 
<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot /var/www/html/apecenergy.co.uk/public_html 
    ServerName www.apecenergy.co.uk 
    ServerAlias apecenergy.co.uk 
    ErrorLog "/var/log/httpd/apecenergy-error_log" 
    CustomLog "/var/log/httpd/apecenergy-access_log" common 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot /var/www/html/plumbing_sites/crouchendplumber.co.uk/public_html 
    ServerName www.crouchendplumber.co.uk 
    ServerAlias crouchendplumber.co.uk 
</VirtualHost> 

回答

1

這只是Ubuntu的Apache的快捷方式組織。它將以同樣的方式工作。您可以使用多個虛擬主機將該長文件保存到您的sites_available文件夾下,然後將其全部啓用。

sudo a2ensite filename 

雖然這是起初方便,你會從長遠來看更好,如果你花時間去他們分開分裂。

+0

我做了嘗試我得到這個消息作爲apache2.service失敗,因爲控制過程退出錯誤代碼。有關詳細信息,請參閱「systemctl status apache2.service」和「journalctl -xe」。 – alwayslearning

+0

那些細節中的具體錯誤是什麼? –