Apache 2.4.6

regarding /etc/httpd/conf/vhosts/host.conf & /etc/httpd/conf.d/ssl.conf

I have both these files and both define VirtualHost This seems like a recipe for disaster?

Should VirtualHost only be defined in one conf file? Which one?

A reason for both?

One better than the other?

  • Are these virtual hosts that you created, or default ones that come preinstalled with centos's apache distribution? Feb 5 at 21:53
  • For Debian/Ubuntu, Virtual hosts get set up in /etc/apache2/sites-available/ and then symlinked to /etc/apache2/sites-enabled/. So my guess is that the vhosts directory is the expected place to define them in CentOS, but I've never used that distribution to configure Apache myself. Feb 5 at 21:55

2 Answers 2


If both files are created during the Apache installation process, you can employ /etc/httpd/conf/vhosts/host.conf to set up virtual hosts for domains, and utilize /etc/httpd/conf.d/ssl.conf to specify SSL certificates for the domains, as demonstrated in the following article:


  • Links can become unavailable, please quote the most relevant part from the link - thanks.
    – dan
    Feb 10 at 1:56
  • @MilesWeb this is only indirectly relevant to the question ask (and contains 1 way of doing this - and arguably not even the way preferred by Apache - and arguably misleading) The Certificates for a VHOST need to be in the VirtualHost section for each Virtualhost to enable the standard name based virtual hosting.
    – davidgo
    Feb 10 at 2:33

A single virtualhost should only be in a single file, however multiple virtualhosts can be put into 1 file, 1 file each or split between files - Apache does not care - in fact, it reads all the files and merges all the contents into its working config.

A standard Apache server can have a single config file (usually /etc/apache2/apache2.conf or /etc/apache2/httpd.conf. There will often be a directive in this file to tell apache to read additional config files - There will typically be a directive "IncludeOptional conf-enabled/.conf" and "includeOptional sites-enabled/.conf which reads these additional directories for their configs.

In fact, the top of the Apache.conf file installed on my fairly typical Ubuntu install summarises it nicely -

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#       /etc/apache2/
#       |-- apache2.conf
#       |       `--  ports.conf
#       |-- mods-enabled
#       |       |-- *.load
#       |       `-- *.conf
#       |-- conf-enabled
#       |       `-- *.conf
#       `-- sites-enabled
#               `-- *.conf
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .