【问题标题】:how to setup multiple vhost in one file如何在一个文件中设置多个虚拟主机
【发布时间】:2016-11-27 08:14:38
【问题描述】:

我从 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 admin@apecenergy
    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 admin@apecenergy
    DocumentRoot /var/www/html/plumbing_sites/crouchendplumber.co.uk/public_html
    ServerName www.crouchendplumber.co.uk
    ServerAlias crouchendplumber.co.uk 
</VirtualHost>

【问题讨论】:

    标签: apache ubuntu virtualhost


    【解决方案1】:

    这只是 ubuntu 对 apache 的快捷组织。它会以同样的方式工作。您可以将包含多个虚拟主机的一个长文件保存到 sites_available 文件夹下的 filename.conf 下,然后一次性启用它们。

    sudo a2ensite filename
    

    虽然一开始这很方便,但如果你花时间把它们分开,从长远来看你会更好。

    【讨论】:

    • 我确实尝试收到此消息 Job for apache2.service failed 因为控制进程退出并出现错误代码。有关详细信息,请参阅“systemctl status apache2.service”和“journalctl -xe”。
    猜你喜欢
    • 2016-11-04
    • 2011-05-13
    • 2017-05-10
    • 2013-03-03
    • 2018-06-27
    • 2016-08-31
    • 1970-01-01
    • 2021-11-01
    • 2013-01-24
    相关资源
    最近更新 更多