create new tag
, view all tags

SID-01991: ConfigureShownAsFile

Status: Answered Answered TWiki version: 6.0.1 Perl version: 5.18.2
Category: CategoryInstallation Server OS: Ubuntu Linux 14.04 LTS Last update: 2 years ago

This is similar to ConfigureDisplaysFile but the SW versions are different - therefore a new topic.

This is definitely not my first TWiki installation but I never stumbled into this problem.

The basic installation is done and I am at the step of calling the configure page the first time.

When I enter "http://localhost/do/configure" the content of the configure script is shown instead of being executed:

#!/usr/bin/perl -wT
# TWiki Enterprise Collaboration Platform, http://TWiki.org/
# Copyright (C) 2000-2014 Peter Thoeny, peter[at]thoeny.org and

I guess that something is wrong with the Apache configuration (which is some kind of magic for me as I don't have the time to buy+read a Apache book just to get it running ...).

I used the configuration tool ApacheConfigGenerator.

The Apache configuration concept seems to have changed since my last installation. It contains enabled- and available-folders now. I guessed that the twiki.conf should be placed into sites-available and created a link to sites-enabled.

In principle the TWiki package seems to be accepted by Apache as Apache logs the access:

::1 - - [19/Nov/2014:10:44:24 +0100] "GET /do/configure HTTP/1.1" 304 181 "-" "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:33.0) Gecko/20100101 Firefox/33.0"

Nothing shows up in Apache's error.log. No TWiki log has been created.

What has to be done to tell Apache to run 'configure' instead of just displaying it?

-- Detlef Marxsen - 2014-11-19

Discussion and Answer

Usually this works pretty straightforward. I am running pretty much the same OS/Perl configuration more or less directly from ApacheConfigGenerator. There are a few things which can go wrong if you want to (or need to) move directories to other places, so let's go trough this step by step:

  • Your interpretation of sites-available and sites-enabled is correct. You don't need to create the symlinks by hand: there's the command a2ensite to do this, and the man entry for the command has some explanations. There's no harm in doing it manually, though: the command just performs a couple of extra consistency checks and then creates the symlink.
  • After having created the symlink you need to restart the Apache (sudo apache2ctl restart) so that the config files are re-read. I guess you've already done this, but if you haven't, you get exactly the symptoms you describe because the values from Apache's global configuration file /etc/apache2/apache.conf are used.
  • A rather unlikely source of problems could be other sites that are also enabled in the sites-available directory which overwrite your configuration.
The interesting part in the configuration file is the mapping of the URL /do/configure to the file .../bin/configure and to tell Apache that this directory contains scripts, not static documents. The ApacheConfigGenerator assumes that you have one root directory for all TWiki files, that's the first parameter of the form. There are a couple of things you can check in your configuration file:
  • There should be two directives in the config file looking like those below. The first line maps URLs starting with /do to files in the directory /var/www/twiki/bin and must be a ScriptAlias directive.
            ScriptAlias /do "/var/www/twiki/bin"
            # The Alias defines a url that points to the twiki pub directory, which
            # is the root of file attachments.
            Alias /pub "/var/www/twiki/pub"
  • The config file should contain two blocks like <Directory "/var/www/twiki/bin"> and <Directory "/var/www/twiki/pub">. The first is for scripts, the second for static data. The directories must be different.
  • In the /var/www/twiki/bin block, the directory path must exactly match the value you provide in the ScriptAlias directive. It must contain two lines Options ExecCGI FollowSymLinks and SetHandler cgi-script. The first line tells Apache to allow execution of scripts in this directory, the second line says which method of script invocation should be used (I assume that you're not using mod_perl).

Good luck!

-- Harald Jörg - 2014-11-21

Hello and thanks for your extensive explanation.

I checked all points you mentioned and found no mistake. Here's the conf file I use:

# Autogenerated httpd.conf file for TWiki.
# Generated at http://twiki.org/cgi-bin/view/TWiki/ApacheConfigGenerator

# IMPORTANT NOTE: Make sure to enable mod_cgi in the primary apache configuration file.

# We set an environment variable called blockAccess.
# Setting a BrowserMatchNoCase to ^$ is important. It prevents TWiki from
# including its own topics as URLs and also prevents other TWikis from
# doing the same. This is important to prevent the most obvious
# Denial of Service attacks.
# You can expand this by adding more BrowserMatchNoCase statements to
# block evil browser agents trying the impossible task of mirroring a twiki
# Example:
# BrowserMatchNoCase ^SiteSucker blockAccess
# BrowserMatchNoCase ^$ blockAccess

BrowserMatchNoCase ^$ blockAccess

&lt;IfModule mod_perl.c&gt;
    # Mod_perl preloading
    PerlSwitches -T

# The ScriptAlias defines the bin directory as a directory where CGI
# scripts are allowed.
# The first parameter will be part of the URL to your installation e.g.
# http://example.com/do/view/...
# The second parameter must point to the physical path on your disc.
ScriptAlias /do "/data/twiki/bin"

# The Alias defines a url that points to the twiki pub directory, which
# is the root of file attachments.
Alias /pub "/data/twiki/pub"

# This specifies the options on the TWiki scripts directory. The ExecCGI
# and SetHandler tell apache that it contains scripts. "Require all granted"
# lets any IP address access this URL.
&lt;Directory "/data/twiki/bin"&gt;
    AllowOverride None
    Require all granted
    Deny from env=blockAccess

    Options ExecCGI FollowSymLinks
    SetHandler cgi-script

    # Password file for TWiki users
    AuthUserFile /data/twiki/data/.htpasswd
    AuthName 'Enter your WikiName: (First name and last name, no space, no dots, capitalized, e.g. JohnSmith)'
    AuthType Basic

    # File to return on access control error (e.g. wrong password)
    ErrorDocument 401 /do/view/TWiki/TWikiRegistration


# 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 TWiki 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
&lt;Directory "/data/twiki/pub"&gt;
    Options None
    AllowOverride None
    Require all granted
    Deny from env=blockAccess

    # Disable execusion of PHP scripts
    #php_admin_flag engine off

    # 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 twiki 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/mod_expires.so
#AddModule mod_expires.c
#&lt;ifmodule mod_expires.c&gt;
#  &lt;filesmatch "\.(jpg|gif|png|css|js)$"&gt;
#       ExpiresActive on
#       ExpiresDefault "access plus 11 days"
#   &lt;/filesmatch&gt;


You may have noticed that I commented-out "php_admin_flag" as keeping it causes Apache to throw an error:

AH00526: Syntax error on line 75 of /etc/apache2/sites-enabled/twiki.conf:
Invalid command 'php_admin_flag', perhaps misspelled or defined by a module not included in the server configuration
Action 'restart' failed.
The Apache error log may have more information.

Until now I thought that this is just another independent issue ... but may be they are interlinked?

... and, yes: The /data/twiki directory exists, contains the bin, pub, etc. directories and the belong to www-data. I'm lost.

Best regards,

-- Detlef Marxsen - 2014-11-23

Thanks for providing the config file! I don't spot an error, but it contains an interesting hint:

# IMPORTANT NOTE: Make sure to enable mod_cgi in the primary apache configuration file.

A wild guess: Maybe you just need to sudo a2enmod cgid (and then, again, sudo service apache2 restart)?

Explanation: Similar to a2ensite, recent Apache installations have a2enmod / a2dismod commands to control modules. In my own Ubuntu 14.04 installation, mod_cgi has been replaced by mod_cgid as the module for CGI invocation for threaded Apache MPM. I don't recall whether I ever had to activate it or whether it was activated per default. However, I did the test of disabling the module - and voila, I get the symptom of configure source code being displayed. If you don't have a threaded Apache, also check cgi instead of cgid. One (exactly one) of those must be present in /etc/apache2/mods-enabled/.

By the way: Commenting out php_admin_flag is definitely an independent issue. I guess you have no PHP installed or mod_php is not enabled, hence Apache has no way to deal with that directive.

-- Harald Jörg - 2014-11-23

a2enmod cgi
did it.

Thanks a lot!

-- Detlef Marxsen - 2014-11-24

      Change status to:
ALERT! If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
Status Answered
Title ConfigureShownAsFile
SupportCategory CategoryInstallation
TWiki version 6.0.1
Server OS Ubuntu Linux 14.04 LTS
Web server Apache 2.4.7
Perl version 5.18.2
Browser & version Firefox 33.0
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2014-11-24 - DetlefMarxsen
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.