This question about Installation of Foswiki: Answered

Multiple instances of Foswiki on one server issue

I wish to have multiple instances/copies of Foswiki on my web server, so that:

  • I would be able to test some settings without affecting other users,
  • prepare for upgrading Foswiki to the latest release (1.2) - I wish to simply copy topics to second instance.

My main Foswiki instalation resides in /var/lbi/foswiki.

I do following steps:

  • sudo cp -avr /var/lib/foswiki/ /var/lib/foswiki2
  • sudo cp -avr /etc/foswiki/ /etc/foswiki2
  • edit /var/lib/foswiki3/bin/LocalLib.cfg. Update paths, so that they will point to proper folders.
  • Generate config file (by means of ApacheConfigGenerator), copy it to the server and activate through a2ensite command
Currently, it seems that I am able to access

However, when I try to access other foswiki copies, let's say:
I receive an 404 error. As I can see in my Apache log, server is redirecting to incorrect path:

File does not exist: /var/lib/foswiki2/foswiki3

Could you tell me what is wrong within my configuration, please?

My .conf file looks as follows (for each copy of Foswiki, the only difference is that 'foswiki2' string is replaced by 'foswiki3' or 'foswiki4'...):

<VirtualHost *:80>
    ServerAdmin webmaster@foswiki2
    DocumentRoot "/var/lib/foswiki2"
    ServerPath /foswiki2
    ServerAlias         # Optional. Add to list of redirect hosts in bin/configure

ScriptAlias http:/ "/var/lib/foswiki2/bin"

# The following Alias is used to access files in the pub directory (attachments etc)
# It must come _after_ the ScriptAlias.
# If short URLs are enabled, and any other local directories or files need to be accessed directly, they
# must also be specified in an Alias statement, and must not conflict with a web name.

Alias http:/ "/var/lib/foswiki2/pub"
Alias http:/ "/var/lib/foswiki2/robots.txt"

#  Rewriting is required for Short URLs, and Attachment redirecting to viewfile
RewriteEngine    on
#RewriteLog "/var/log/apache/rewrite.log"
#RewriteLogLevel 0

#support the cgi-bin url's
RedirectMatch ^/cgi-bin/foswiki2/(.*)$ /foswiki2/bin/$1

RedirectMatch ^/foswiki2/?$ /foswiki2/bin/view$1
RedirectMatch ^/foswiki2(/([A-Z].*)?)?$ /foswiki2/bin/view$1

# short urls
Alias http:/ "/var/lib/foswiki2/bin/view"
RewriteRule ^http:/*) http:/$1 [L,NE,R]
RewriteRule ^http:/$ http:/ [L,NE,R]

# This enables access to the documents in the Foswiki root directory

<Directory "/var/lib/foswiki2">
    Order Allow,Deny
    Allow from all
    Deny from env=blockAccess

# This specifies the options on the Foswiki scripts directory. The ExecCGI
# and SetHandler tell apache that it contains scripts. "Allow from all"
# lets any IP address access this URL.
# Note:  If you use SELinux, you also have to "Allow httpd cgi support" in your SELinux policies

<Directory "/var/lib/foswiki2/bin">
    AllowOverride None

    Order Allow,Deny
    Allow from all
    Deny from env=blockAccess

    Options +ExecCGI  -FollowSymLinks
    SetHandler cgi-script

    # Password file for Foswiki users
    AuthUserFile "/var/lib/foswiki2/data/.htpasswd"
    AuthName 'Enter your WikiName: (First name and last name, no space, no dots, capitalized, e.g. JohnSmith). Cancel to register if you do not have one.'
    AuthType Basic

    # File to return on access control error (e.g. wrong password)
    ErrorDocument 401 http:/

    # Limit access to configure to specific IP address(es) and user(s).
    # Make sure configure is not open to the general public.
    # It exposes system details that can help attackers.
    # cf. for details.
<FilesMatch "^(configure)$">
    SetHandler cgi-script
    Require user admin

    <FilesMatch "(attach|edit|manage|rename|save|upload|mail|logon|rest|.*auth).*">
        Require valid-user

# This sets the options on the pub directory, which contains attachments and
# other files like CSS stylesheets and icons. AllowOverride None stops a
# user installing a .htaccess file that overrides these options.
# Note that files in pub are *not* protected by Foswiki Access Controls,
# so if you want to control access to files attached to topics you need to
# block access to the specific directories same way as the ApacheConfigGenerator
# blocks access to the pub directory of the Trash web
<Directory "/var/lib/foswiki2/pub">
    Options None
    Options -FollowSymLinks
    AllowOverride None

    Order Allow,Deny
    Allow from all
    Deny from env=blockAccess
    ErrorDocument 404 http:/

   # This line will redefine the mime type for the most common types of scripts
    AddType text/plain .shtml .php .php3 .phtml .phtm .pl .py .cgi
   # add an Expires header that is sufficiently in the future that the browser does not even ask if its uptodate
   # reducing the load on the server significantly
   # IF you can, you should enable this - it _will_ improve your Foswiki experience, even if you set it to under one day.
   # you may need to enable expires_module in your main apache config
   #LoadModule expires_module libexec/httpd/
   #AddModule mod_expires.c
   #<ifmodule mod_expires.c>
   #  <filesmatch "\.(jpe?g|gif|png|css(\.gz)?|js(\.gz)?|ico)$">
   #       ExpiresActive on
   #       ExpiresDefault "access plus 11 days"
   #   </filesmatch>
   # Serve pre-compressed versions of .js and .css files, if they exist
   # Some browsers do not handle this correctly, which is why it is disabled by default
   # <FilesMatch "\.(js|css)$">
   #         RewriteEngine on
   #         RewriteCond %{HTTP:Accept-encoding} gzip
   #         RewriteCond %{REQUEST_FILENAME}.gz -f
   #         RewriteRule ^(.*)$ %{REQUEST_URI}.gz [L,QSA]
   # </FilesMatch>
   # <FilesMatch "\.(js|css)\?.*$">
   #         RewriteEngine on
   #         RewriteCond %{HTTP:Accept-encoding} gzip
   #         RewriteCond %{REQUEST_FILENAME}.gz -f
   #         RewriteRule ^([^?]*)\?(.*)$ $1.gz?$2 [L]
   # </FilesMatch>
   # <FilesMatch "\.js\.gz(\?.*)?$">
   #         AddEncoding x-gzip .gz
   #         AddType application/x-javascript .gz
   # </FilesMatch>
   # <FilesMatch "\.css\.gz(\?.*)?$">
   #         AddEncoding x-gzip .gz
   #         AddType text/css .gz
   # </FilesMatch>


# Security note: All other directories should be set so
# that they are *not* visible as URLs, so we set them as =deny from all=.
<Directory "/var/lib/foswiki2/data">
    deny from all

<Directory "/var/lib/foswiki2/templates">
    deny from all

<Directory "/var/lib/foswiki2/lib">
    deny from all

<Directory "/var/lib/foswiki2/locale">
    deny from all

<Directory "/var/lib/foswiki2/tools">
    deny from all

<Directory "/var/lib/foswiki2/working">
    deny from all

BrowserMatchNoCase ^$ blockAccess


-- MateuszKDzior - 16 Jun 2015

I've never seen ServerPath used for vhost selection. The Apache docs state that it's needed when an HTTP 1.0 client that does not provide the Host: header is used. I suspect that you are running into an apache issue here and not Foswiki.

Can you have DNS entries added so you actually use multiple hostnames? and I've used that for virtual hosting many times and it works well.

I think you could also put two foswiki installations into the same virtual host by "doubling up" all of the configuration settings with two separate prefixes. Completely configure the /var/lib/foswiki and /var/lib/foswiki2 paths in a single host. For example:
ScriptAlias http:/ "/var/lib/foswiki1/bin"
ScriptAlias http:/ "/var/lib/foswiki2/bin"

Alias http:/ "/var/lib/foswiki1/pub"
Alias http:/ "/var/lib/foswiki1/robots.txt"

Alias http:/ "/var/lib/foswiki2/pub"
Alias http:/ "/var/lib/foswiki2/robots.txt"

... and so on...

-- GeorgeClark - 16 Jun 2015

thank you for quick answer.

Regarding multiple DNS entries, I guess I will be unable to do that. According to Apache docs:
Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site.

so I guess that your solution with one virtual host is an option for me.

Let me ask you if I understood properly - I should have only one foswiki.conf file with following content:

<VirtualHost *:80>
    ServerAdmin webmaster@foswiki
    DocumentRoot "/var/lib/"

ScriptAlias http:/ "/var/lib/foswiki2/bin"
ScriptAlias http:/ "/var/lib/foswiki3/bin"

and other entries repeated for each foswiki instance?

-- MateuszKDzior - 17 Jun 2015

Yes. foswiki.conf is really an apache config file, So you are telling apache that there are two foswiki installations, one under foswiki2 and one under foswiki3. I have not actually tested this configuration, but I don't see why it won't work.


-- GeorgeClark - 17 Jun 2015

Just a last question.

What if I wish to use mod_perl (as mentioned in Support.Question1615).

I'm particular interested in following lines in my .conf file.

<IfModule mod_perl.c>
PerlSwitches -wT
# must exist, otherwise Apache will not start.
PerlRequire "/var/lib/foswiki/tools/"

They point to, where I have document root set to path of the main instance of Foswiki. I guess it will not work with different instances. To be honest, from my point of view it will be okay to use mod_perl only for the main Foswiki. However, how can I accomplish that?

-- MateuszKDzior - 19 Jun 2015

Unfortunately I have no idea. I have not used mod_perl.

-- GeorgeClark - 19 Jun 2015

Okay, it works correctly for me.

I use mod_perl for the main Foswiki instance only, so that only in the case of main Foswiki instace mentioned script is run.

-- MateuszKDzior - 29 Jun 2015

QuestionForm edit

Subject Installation of Foswiki
Version Foswiki 1.1.9
Status Answered
Related Topics
Topic revision: r8 - 29 Jun 2015, MateuszKDzior - This page was cached on 30 Mar 2017 - 13:03.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License