InstallApacheVirtualHost

Jason Fesler edited this page Oct 27, 2016 · 8 revisions

Note: This requires mod_ip, see [InstallModIP] if you haven't already installed it.

/etc/httpd/conf/httpd.conf

If you have a file called /etc/httpd/conf/httpd.conf, you may need to make changes to it.

If you plan on putting your project in a different directory, you might need to make a new statement to cover that directory instead.

In particular, the <Directory /var/www/html> needs to be told about Multiviews; and it also needs to be told about AllowOverride (if you wish to trust the project's .htaccess files):

<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
    Options MULTIVIEWS Indexes FollowSymLinks


#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride ALL

#
# Controls who can get stuff from this server.
#
    Order allow,deny
    Allow from all

</Directory>

Example short config

You'll find this in the main content's /example-short.conf. Note that this example depends on the distributed content's ".htaccess" files, which are maintained for you.

#####################################################################
# Example virtual host configuration file, with .htaccess files.    #
# This is the recommended format, as it will permit mirrors to      #
# automatically update to the latest settings.                      #
#####################################################################


<VirtualHost *:80>
ServerName test-ipv6.example.com
ServerAlias *.test-ipv6.example.com
ServerAlias 192.0.2.1
ServerAlias 2001:db8::1
ServerAlias 2001:db8::1280

# Additional aliases, if you want to consider
# https://github.com/falling-sky/source/wiki/TransparentMirror 
# By request for jfesler@test-ipv6.com
ServerAlias test-ipv6.com
ServerAlias *.test-ipv6.com
ServerAlias testipv6.com
ServerAlias *.testipv6.com
ServerAlias test-ipv4.com
ServerAlias *.test-ipv4.com
ServerAlias testipv4.com
ServerAlias *.testipv4.com
ServerAlias test-ds.com
ServerAlias *.test-ds.com
ServerAlias testds.com
ServerAlias *.testds.com
ServerAlias test-v6.com
ServerAlias *.test-v6.com
ServerAlias testv6.com
ServerAlias *.testv6.com

DocumentRoot /usr/local/www/data/virt/test-ipv6.example.com
<Directory /usr/local/www/data/virt/test-ipv6.example.com>
AllowOverride All
</Directory>
</VirtualHost>

Example long config

You'll find this in the main content's /example-long.conf. Note that this example ignores the distributed .htaccess files. Do this if you have less trust during updates. Recommend.. only for the truly paranoid. Otherwise, this is just more work in the long run.

You can view the example-long.conf online here: http://test-ipv6.com/vhost-long.conf.example

(We are no longer showing it directly on the wiki, as the wiki can be out of date).

By using the long config, you'll not track language additions or other updates. You'll be expected to (somehow) keep track of changes. By failing to do so, you may actually break functionality on the site. We strongly recommend using the short method instead, and allowing the bundled .htaccess file to do the job.

Testing

If you have installed mod_ip, you can test the virtual host by trying to bring up http://test-ipv6.example.com/ip/ (substitute the appropriate hostname). You should see something like this:

    callback({"ip":"203.0.113.1","type":"ipv4","subtype":"","padding":""})