Dynamic Virtual Hosts In Apache

My httpd - vhosts.conf documents resembles this:

<VirtualHost *:80>
DocumentRoot "/www/foo/htdocs"
ServerName foo
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/www/bar/htdocs"
ServerName bar
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "/www/baz/htdocs"
ServerName baz
</VirtualHost>

Notice the pattern? Exists any kind of means to lower the replication, or am I stuck to having a different VirtualHost access for each and every website?

0
2019-05-18 23:03:31
Source Share
Answers: 3

There are 2 really various solutions.

  1. Make use of the "subdomain - as - account - folder" method.
  2. Write a brief manuscript and also arrangement documents that with each other create your httpd - vhosts.conf documents (s) dynamically. After that the manuscript and also arrangement become your masters, and also the.conf documents are "expendable."

I advise # 2, and also I assume the Pragmatic Programmers could too.

0
2019-05-21 09:35:43
Source

I recommend you look at the Apache internet site for vibrant digital hosts. The various other approaches call for a reactivate of the Apache web server.

http://httpd.apache.org/docs/2.0/vhosts/mass.html

0
2019-05-21 09:34:53
Source

I identified just how to do it after reviewing Dark Ninja is solution. Below is what my httpd - vhosts.conf documents resembles currently.

# Dynamic virtual hosts.
# See http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html
UseCanonicalName Off
VirtualDocumentRoot /www/%0/htdocs/

I additionally needed to enable mod_vhost_alias by uncommenting this line in httpd.conf

LoadModule vhost_alias_module modules/mod_vhost_alias.so
0
2019-05-21 07:37:48
Source