Tags:
installation4Remove my vote on this tag windows1Add my vote for this tag create new tag
view all tags
ALERT! NOTE: This is a HistoricalDocument topic. It used to be distributed in an earlier TWiki release, but is no longer part of the official TWiki distribution. Post questions, error notes, and suggestions concerning the documentation of this topic in the comments section below! Use the Support web for problems you are having using TWiki.

ALERT! NOTE: This is a SupplementalDocument topic which is not included with the official TWiki distribution. Please help maintain high quality documentation by fixing any errors or incomplete content. Put questions and suggestions concerning the documentation of this topic in the comments section below! Use the Support web for problems you are having using TWiki.

Windows Install Cookbook

For a very simple and virtually foolproof installation, with no TWiki or web server knowledge required, see DownloadTWikiVM.

For a very simple install process, suitable for most Windows users wanting a personal wiki, see IndigoPerlCookbook and TWiki04x02WindowsInstallationGuide (for a manual installation process). This is known to work well for TWiki-4.0.0 and later. Not quite as foolproof as DownloadTWikiVM, but requires less RAM.

For personal use on Windows try TWikiForWindowsPersonal, which has an even simpler unzip and start "installation".

Introduction

NOTE: This document is outdated, it has not been updated for TWiki 4.1. So check the official TWiki manuals at TWikiDocumentation first, as these have been updated for 4.1, or use one of the alternatives listed on top of this document. In particular, it is now essential to use absolute paths in setlib.cfg with TWiki 4.0, which was not the case for the Sep 2004 release. Also, testenv should not now be used - its replacement, configure, is even better as it also lets you configure TWiki without editing configuration files.

For the cookbook for TWiki 4.1 on Windows, please use WindowsInstallCookbookForTWiki04x01

If you are reading this on your own copy of TWiki, please stop and get the latest version from TWiki:TWiki.WindowsInstallCookbook, as it may have useful improvements or fixes.

This cookbook is intended to get you up and running with TWiki on Windows quickly, with as few problems as possible. The 'cookbook' approach is simply to restrict the many choices that someone installing TWiki must make, so that a reasonably well-defined procedure can be followed - new users can simply follow the steps, while experts can use this as more of a guideline.

  • NOTE: This cookbook is not 100% complete (e.g. it doesn't cover authentication setup described by existing documentation), but it has been used successfully for several years - it is quite accurate and should get you started if you follow the instructions. Please provide feedback in TWiki:Codev.WindowsInstallCookbookComments.
  • NOTE: You will get the best results from following this cookbook exactly, using the same directories, etc - however, if you really do need to vary things, it should be fairly obvious what to do.

-- RichardDonkin - 10 Dec 2004

Summary

NEW - See WindowsInstallSummary for a concise summary of the whole cookbook.

Recent updates

  • 04 Mar 2005 - updated for TWiki:Codev.TWikiRelease02Sep2004 and Windows permissions settings, by JuditMays
  • 10 Dec 2004 - updated to remove warning on Perl 5.8, updated most package versions, mentioned XP more, removed TWiki 2001 release specifics, added pointer to TWiki:Codev.ApacheTwoBreaksNonUTF8EncodedURLsOnWindows
  • 01 Nov 2004 - updated to reflect absence of perl 5.6.1 in many cygwin mirrors
  • 28 Jun 2004 - updated to reflect experiences installing beta20040507 on Windows NT
  • 2 Jun 2003 - updated to include setting HOME since this is not always picked up by Cygwin
  • 30 Apr 2003 - New issue with Perl 5.8 found, added warning not to use Perl 5.8
  • 02 Mar 2003 - updated to restrict register script edits to Dec 2001 release
  • 30 Nov 2002 - added binutils to list of Cygwin packages, and added warning not to use Apache 2.0
  • 20 Nov 2002 - update to avoid TWiki:Support.InstallDigestSHA1Fails when installing Digest::SHA1 on Windows 2000
  • 12 Nov 2002 - setting SMTPMAILHOST for user registration and notification
  • Older changes are in TWiki:TWiki.WindowsInstallCookbookHistory

Scope

This document covers installation of the TWiki 02-Sep-2004 production release (TWiki:Codev/TWikiRelease02Sep2004) in the following environment - if you want to use a different environment, feel free to use this as a guideline only.

Component Name, version Comment
Operating System Windows 2000 or XP Should also work for Windows NT
Web Server Apache 1.3.33 Check latest version at http://75mmg6t6gjgr3exehkae4.roads-uae.org, but don't use Apache 2.0 yet
Unix tools Cygwin 1.5.14 Simplest way to get a whole set of required tools - later versions should be fine
Perl Cygwin perl-5.8.5-3 Comes with Cygwin, Perl 5.8 is now fine
RCS Cygwin rcs-5.7-3 Comes with Cygwin

Why this choice of packages? Because I've tried them, and they work well, without requiring a complicated setup... In particular, Apache is the commonest choice for TWiki on Unix/Linux, Cygwin Perl is very close to Unix Perl, and the Cygwin RCS is regularly updated. Cygwin also lets you install the Unix tools, Perl and RCS in a single step, saving quite a lot of time. If you ever need to install TWiki on Unix/Linux, you'll find this setup is very similar.

More recent minor versions should be OK, but they can introduce bugs.

NEW Major version upgrades, such as Apache 2.0 or Perl 5.10, are very likely to cause problems - for example, Apache 2.0 is unable to authenticate users created by the current TWiki user registration script (due to a feature being removed in 2.0, see TWiki:Support.FailedAuthenticationWithApache2OnWinNT). Even though the Apache group says that Apache 2.0 is the best version, that's not true for TWiki on Windows at present (and particularly not true for sites using internationalisation - see TWiki:Codev.ApacheTwoBreaksNonUTF8EncodedURLsOnWindows). For more information, see TWiki:Codev.IssuesWithApache2dot0.

Alternatives

The following Windows operating systems have been tested following the instructions given here:
  • Windows NT, 98 and ME all work fine with minor tweaks
  • Windows XP works fine, though setting the Windows permissions is important (covered below)

There are doubtless other combinations of components that may work - in particular:

  • TWiki:Codev.ActiveState Perl involves only minor changes to TWiki.cfg, and is probably a simpler choice if you need an easy way to install mod_perl (see TWiki:Codev.ModPerl). TWiki:Codev.ActiveState Perl can be substituted without too much hassle, and in fact the same TWiki.cfg can be used for both TWiki:Codev.ActiveState and Cygwin Perl.
  • Using a different web server is certainly possible, but the setup required for each web server varies greatly (see TWiki:Codev.TWikiOnWindows for pages about specific web servers). You may find it easiest to get a working system with Apache and then switch over to another web server.

Covering the whole range of additional possibilities, particularly web servers, would make this cookbook too complex, and is best handled as a separate activity.

For improved performance on Windows through using mod_perl, you may want to try TWiki:Codev.WindowsModPerlInstallCookbook.

Checking versions

If you already have some of these add-ons installed, here's how to check the versions - this assumes you have TWiki:Codev.CygWin already installed:

   $ : Cygwin DLL version is the number in 1.5.x format
   $ uname -r
   $ less c:/your-apache-dir/Announcement
   $ perl -v
   $ rcs -V

If you have an older version of any component, do yourself a favour and upgrade it as part of the install process.

Pre-requisites and upgrades

You will need to have local administrator rights and be comfortable with Windows administration.

This cookbook is intended for a clean install, i.e. none of these components are already installed. However, since Cygwin and Apache's installation process is fairly upgrade-friendly, upgrades should work as well - take backups of all your data and config files first, though!

Text editing

Editing Cygwin files should be done with an editor that can handle Unix file format (see the Cygwin binary mode section below). The installation process suggests:
  • nano, a very simple text editor, installed optionally during Cygwin installation. Always launch nano with the -w command-line option to turn off wrapping of long lines.
  • vim, a more sophisticated vi compatible editor that should be familiar to most Unix users
These are both non-GUI editors, but if you prefer to use a GUI editor you can install PFE, a freeware editor that supports Unix format files. PFE is available on download.com and Simtel.

Another good TWiki:Codev.OpenSource editor is SciTE (aka WSciTE), available at http://d8ngmj9myunffk5uhkae4.roads-uae.org/SciTE.html.

The Unix/Windows Environment

It's a little known fact that you can use pathnames such as c:/apache almost everywhere in Windows - try it in a File Open dialogue box. The main exception is the Windows "DOS" command line shell - here, you must use double quotes around forward slashes, e.g. dir "c:/apache" will work fine.

The reason this matters is that '\' is a special character to Perl and other tools, so it's much easier to use '/' everywhere.

The Cygwin environment

TWiki:Codev.CygWin is a Unix-like environment for Windows - many of its tools support the c:/apache format, but it also provides a more Unixlike syntax, e.g. /usr/bin/rcs.exe, because some Unix tools ported onto Cygwin only support the Unix format.

When you launch a Cygwin shell, your existing PATH variable is translated from the Windows format to the Unix format, and the ';' separators in the Windows PATH are changed into ':' separators as required by Unix. A Cygwin tool (e.g. Cygwin Perl or Cygwin RCS) will always use the Unix PATH format, and will accept Unix format pathnames.

The Apache environment

Apache runs as a native Windows process and has nothing to do with Cygwin (at least the version used in this cookbook doesn't). Hence it supports c:/ pathnames in its config files and the first line of Perl CGI scripts.

If you need to use spaces in file names (not recommended), put double quotes around the file name in the httpd.conf file. There have been some security-related bugs in Apache with long pathnames, which are a bit more likely if you use spaces, so it's best to just avoid long names and using spaces.

The Perl environment

Once Perl has been launched by Apache, it is in Cygwin mode, and so is everything it launches, including ls, egrep, and the RCS tools that it (typically) launches with the bash shell.

If you need to use spaces in file names (not recommended), you may be able to put double quotes around the file name in the TWiki.cfg file - however, it's not clear whether all the TWiki code would work with this.

Installing Components

Enough background, let's get on with the installation.

TWiki (part 1)

Head to http://50nm7panwb5tevr.roads-uae.org, click the download link, and fill in the form to request a URL for download. You'll get an automated email, which should arrive by the time you need it.

Apache

Steps 1 and 2 can be shortcut by opening the self-installing executable on the Apache website that installs Apache 1.3.x. The painful details below are mainly helpful when detecting where things are going wrong.....

1. Download Apache

  • NOTE: If you are using Windows NT, download the .MSI installer (instmsi.exe) from the Apache Win32 download page - this enables you to install .MSI files. You may need to update the .MSI Installer if you have an old version under NT.
  • NOTE: The Apache package itself requires a download of around 2 MB, and up to 10 MB of free disk space once installed

2. Install Apache

  • Double-click the .MSI file to run the installer
  • Specify c:\ as the installation directory - this actually installs Apache into c:\apache (if you specify c:\apache, it installs into c:\apache\Apache). Putting Apache into c:\Program Files is not recommended for easy editing of Apache config files from Cygwin.
  • On Windows NT/2000/XP you can choose to run Apache as a service or as a normal program - see the Apache docs for details.

3. Test Apache

  • If necessary, start apache, by selecting 'Start' from the 'Start->Programs->Apache...->Control Apache Server' menu.
  • Point your browser at http://f2t57d1uwnc0.roads-uae.org/ to see the Apache intro page.

Congratulations, you now have a working web server!

To restart Apache after changing its config, type:

  • apache -k restart for standalone Apache process running in another window
  • apache -k restart -n apache for Apache running as a Win2000 service (-n gives name of service)

Another useful command is apache -k stop.

Cygwin, Unix tools, Perl and RCS

4. Install Cygwin

Head to http://6wwq0thh2w.roads-uae.org, and click the cygwin-icon.gif Install or update now! link. Save the setup.exe in a directory, e.g. c:\download\cygwin-dist.

Now run the Cygwin setup.exe file - this will also install Perl and RCS in one fell swoop.

  • Choose Internet install
  • On first page, accept the defaults (be sure that the default text file type is Unix to avoid problems with attachment uploads, and specify 'install for all users')
  • Select c:\download\cygwin-dist as the local package directory, and suitable proxy settings, then pick a local mirror site
  • In the package list screen, hit the View button until you get an alphabetical list that says Full to the right of the button.
  • Leave the radio button on Curr (Current)
    • The Current column shows what's installed on your system (if anything)
  • For each package, make sure the New column in the installer has a version number under it. If it says 'Skip' or 'Keep' (meaning it's already installed), single-click that word until a version number is shown.
  • Make sure you select the following packages - :
    • bash
    • binutils
    • coreutils
    • diffutils
    • gcc
    • grep
    • gzip
    • make
    • nano (or vim if you prefer the vi editor)
    • ncftp
    • pcre
    • perl (5.8.5-3 or higher)
    • rcs (5.7-3 or higher)
    • tar
    • unzip
    • w32api
    • wget (optional, useful for Perl install and TWiki:Codev.ReadWriteOfflineWiki)
    • NOTE: Do not include lynx if you are upgrading from an older Cygwin installation (to avoid annoying DLL messages) - if you want Lynx, read the Cygwin FAQ entry and upgrade libncurses5.
  • Hit Next to do the installation.
    • NOTE: The mandatory packages require a download of about 12 MB - about half of this is Perl, which would be necessary even without Cygwin, and most of the rest is gcc, which is required for simple installation of Perl modules that use the C language. A default installation of Cygwin 1.5.10, plus required packages, needs around 150 MB of free disk space - if you are tight on disk space or Internet bandwidth, de-select all but the mandatory packages, but if not, there is no harm in downloading more.
    • NOTE: The installer keeps a local copy of downloaded files, so it's easy to re-install without re-downloading.
  • Let the installer create the shortcuts suggested
  • You can always come back and re-run the installer again later if you missed anything.

Environment setup:

  • Set the HOME environment variable to c:\cygwin\home\YOURUSER, where YOURUSER is your userid, e.g. jsmith or administrator.
    • On Windows NT, XP and 2000: Go into Control Panel, double-click the System icon, and select Advanced, then click Environment Variables. Under User Variables, click New.... Now type HOME (must be upper case) as the variable name, and c:\cygwin\home\YOURUSER as the value, and hit OK.
    • On Windows 98 and ME - add to AUTOEXEC.BAT and reboot
  • You can also set TEMP to c:\temp at this point, if you prefer this to editing the Cygwin ~/.profile file. (HOME can't be set in the ~/.profile file.)
  • Create the c:\cygwin\home\YOURUSER directory

5. Test Cygwin

  • Launch the desktop icon - this runs the bash shell, which has command line editing features
    • Use the cursor up key to recall previous commands - normal PC editing keys can then be used to edit a command
    • TIP: When typing a directory or file name, hit the TAB key after the first few letters of the name - bash will 'complete' the name. If bash beeps at you, hit TAB again to see the files/directories that match the name so far, and type a bit more before hitting TAB. This saves a lot of time!
  • Type rcs -V - you should see the RCS version, 5.7
  • Type perl -v - you should see cygwin mentioned in the first line, and the Perl version, 5.8.5-3 or higher
  • Type grep home /etc/passwd - you should see some output.

The Cygwin User Guide is well worth reading for some background on how Cygwin works.

6. Configure Cygwin for binary mode

  • This is very important - omitting this step leads to a partially working system that corrupts RCS files - without this, Cygwin tools (including Perl and RCS) will add unwanted carriage returns (Ctrl/M, '\r') to files in an attempt to translate between the Windows and Unix text file formats (Unix text files only use line feeds ('\n').
  • Stay in the Cygwin (bash) shell, and type the following (use only forward slashes, i.e. '/'):
   $ mkdir /twiki /c c:/twiki
   $ mount -b -s c:/twiki /twiki
   $ mount -b -s c:/ /c
   $ mount -b -c /cygdrive
   $ mount
   C:\cygwin\bin on /usr/bin type system (binmode)
   C:\cygwin\lib on /usr/lib type system (binmode)
   C:\cygwin on / type system (binmode)
   c:\twiki on /twiki type system (binmode)
   c: on /c type system (binmode)
  • This configures /twiki (known as a 'mount point') to map onto c:/twiki and for that directory tree to always be in binary mode, and does the same for /c, mapping it onto c:/. The last-but-one command sets binary as the default for any unmounted drives (e.g. z:/, aka /cygdrive/z).
  • It is very important that all lines in the output of mount say '(binmode)' at the end of each line
    • If the lines for C:\cygwin directories do not, you should uninstall and then re-install Cygwin to ensure that binary attachment uploads will work.
  • You can now refer to files using Unix paths, e.g. /twiki/bin/view or /c/apache/Announcement - see the Cygwin documentation for more details on this.
  • Now test this, still using the Cygwin shell:
    • Type cd /twiki
    • Type echo hi >t
    • Type cat -v t - you should see hi as the output
    • If you see filename errors, your mounts did not work for some reason - check your typing
    • If you see hi^M as output, your /twiki directory is not in binary mode
    • Clean up by doing rm t

This setup is written to the Windows registry, so there's no need to put these commands into a .profile file. For more information on binary vs text mode, see this User Guide section and this FAQ entry.

TWiki (part 2)

7. Download TWiki

Download the latest TWiki release from http://50nm7panwb5tevr.roads-uae.org/ and save it in the c:/twiki directory.

8. Install TWiki

Unzip the downloaded ZIP file under c:/twiki using WinZip, or by going into Cygwin and doing the following - you can hit the TAB key to complete filenames after you've typed the first part:

   $ cd /twiki
   $ unzip TWiki20040209.zip

Configuring components

Now that all the components are installed, you need to configure them.

Configuring Apache

The setup given here is fairly simple, in that it allows only TWiki to be served by the web server. For more complex setups, you can investigate the Alias and ScriptAlias commands that are left commented out in this configuration.

  • NOTE: This needs reviewing for security holes and to ensure nothing is missed, though this config does work.

1. Configure Apache (part 1)

Using a suitable text editor (see #TextEditing, above) edit c:/apache/conf/httpd.conf as follows - this tells Apache where TWiki lives, and removes the need to tinker with the Windows environment settings.

  • Note the trailing '/' characters in various places - they are important!

  • Create the c:\temp directory, by typing mkdir c:\temp in a DOS command line window
  • Edit the following lines, some of which already exist in the file:

# Change this to point to the Apache administrator (e.g. you)
ServerAdmin you@yourdomain.com

# Replaces DocumentRoot "C:/apache/htdocs"
DocumentRoot "C:/twiki"

# Replaces <Directory "C:/apache/htdocs">
<Directory "C:/twiki">

  • Add the following lines - the Alias and ScriptAlias lines can be omitted in this setup

# Alias /twiki/ "C:/twiki/"
# ScriptAlias /twiki/bin/ "C:/twiki/bin/"
<Directory  "C:/twiki/bin/">
    # RD: Changed None to All in next line, to enable .htaccess
    AllowOverride All
    Allow From All
    Options  ExecCGI
    SetHandler cgi-script
</Directory>

# Environment setup required to run Apache as service or as a
# standalone process.
<IfModule mod_env.c>
   # Adjust TZ for your server timezone, e.g. EST5EDT - put the non-daylight-savings
   # timezone code first (e.g. EST or GMT), followed by the number of hours that it's behind GMT 
   # during non-daylight-savings time (use '-5' for timezones in advance of GMT).
   SetEnv TZ GMT0BST
   SetEnv RCSINIT -x,v/
   # Adjust TEMP and TMP for your server and create directories if necessary
   SetEnv TEMP c:/temp
   SetEnv TMP c:/temp
   SetEnv LOGNAME system
   SetEnv HOME c:/twiki
</IfModule>

2. Configure Apache (part 2)

Add an AddHandler line to the <IfModule mod_mime.c> section of httpd.conf - this removes the need to rename all the TWiki CGI scripts later in the installation.

  • Note the trailing '.' on the AddHandler line.
#
# Document types
#
<IfModule mod_mime.c>
    # TWiki setup - avoid renaming scripts
    AddHandler cgi-script .
...

Remember to restart Apache after the configuration.

Configuring Cygwin

3. Configure Cygwin

Open the windows explorer, right click your cygwin directory (c:/path/to/cygwin) and choose "Properties". Select the "Security" tab and set the permissions as follows:

  1. uncheck 'inherit permissions', slap the 'copy existing' button when prompted (In WinXP, you set this through the "Advanced" button)
  2. for the 'Everyone' or 'Users' group, uncheck Write access and Full Control
  3. Add the groups CREATOR OWNER, SYSTEM and give them Full Control
  4. Add the users Administrator, Your_Name and give them Full Control

TIP Note, if the "Security" tab doesn't appear in your "Properties" dialog, see this article.

Configuring TWiki

4. Configure TWiki

Edit the TWiki config file, c:/twiki/lib/TWiki.cfg (or in Cygwin terms, /twiki/lib/TWiki.cfg) as follows:

  • NOTE: It should be possible to use c:/twiki format pathnames for Cygwin, given the above binmode setup, but I have not tested this fully - a Cygwin Perl test script does generate binary mode files in this configuration, so it should work with RCS as well (really need a small RCS file corruption test case). Watch out for RCS file corruption carefully if you do try c:/twiki pathnames with Cygwin, and do report your experiences...
  • NOTE: Current versions of Cygwin create 'symbolic links' from fgrep and egrep to grep, requiring the settings for these commands to point directly to grep as below (with suitable flags to provide fgrep and egrep behaviour).

# variables that need to be changed when installing on a new server:
# ==================================================================
#                   /cgi-bin/view/Main/WebHome : link of TWiki icon in upper left corner :
$wikiHomeUrl      = "http://f2t57d1uwnc0.roads-uae.org/bin/view";
#                   Host of TWiki URL :    (Example "http://0rwz0up3.roads-uae.org:123")
$defaultUrlHost   = "http://f2t57d1uwnc0.roads-uae.org";
#                   /cgi-bin : cgi-bin path of TWiki URL:
$scriptUrlPath    = "/bin";
#                   /p/pub : Public data path of TWiki URL (root of attachments) :
$pubUrlPath       = "/pub";

# NOTE: Next three settings should be valid absolute pathnames using Cygwin; if using
# TWiki:Codev.ActiveState Perl, use z:/twiki format pathnames if your TWiki directory is not on C:.

#                   Public data directory, must match $pubUrlPath :
$pubDir           = "/twiki/pub";
#                   Template directory :
$templateDir      = "/twiki/templates";
#                   Data (topic files) root directory :
$dataDir          = "/twiki/data";

....

#                   Set ENV{'PATH'} explicitly for taint checks ( #!perl -T option ) :
#                   (Note: PATH environment variable is not changed if set to "")

# On Windows, $safeEnvPath needs only one component, the directory where RCS is installed
# - used by 'rcsdiff' to run 'co' program, so PATH must be correct.

# Unix/Linux setting:
# $safeEnvPath      = "/bin:/usr/bin";

# Using Cygwin perl, so can use Unix-like paths, with ':' as separator.
# Note that /usr/bin and /bin are identical due to default /usr/bin mount
# in Cygwin.  Must NOT use 'c:/foo' type paths, as ':' is taken as separator
# meaning that 'c' is interpreted as a pathname, giving Perl taint error.
$safeEnvPath      = "/bin";

# If using ActiveState perl, use Windows paths instead
# $safeEnvPath      = "c:/cygwin/bin";

...

#                   RCS directory (find out by 'which rcs') :
$rcsDir           = "c:/cygwin/bin";

...

#                   Unix egrep command :
$egrepCmd         = "/bin/grep -E";
#                   Unix fgrep command :
$fgrepCmd         = "/bin/grep -F";

For the cookbook install using Cygwin Perl, there's no more TWiki.cfg editing to be done, so you can get onto the next section.

#                   NOTE: When using ActiveState Perl, you must specify
#                   a full Windows-style pathname, using '\\' for backslashes,
#                   for the ls, egrep and fgrep commands, because Cygwin's shell
#                   is not used - forward slashes are OK in Windows everywhere
#                   except in the cmd.exe shell. Drive letters are OK - e.g.
#                   'c:\\foo\\ls' will work.  When using Cygwin perl, just
#                   use the default '/bin/ls' type settings.
#
#                   Unix ls command :
$lsCmd            = "c:\\cygwin\\bin\\ls";
#                   Unix egrep command :
$egrepCmd         = "c:\\cygwin\\bin\\grep";
#                   Unix fgrep command :
$fgrepCmd         = "c:\\cygwin\\bin\\grep";

Now you need to edit the file /twiki/bin/setlib.cfg:

    • Set $twikiLibPath to the absolute file path /twiki/lib (default is ../lib).
    • ALERT! NOTE: Do not leave it as a relative "../lib" path or Plugins might fail to initialize properly

Editing the CGI scripts

5. Editing the Shebang lines

Now to edit the curiously named 'shebang lines' at the top of the TWiki CGI scripts. This is required so the Apache server knows what interpreter (perl) to use with the scripts.

  • You must use the Cygwin shell to do this (unless you are a Perl expert) - don't use the Windows command shell, cmd.exe (aka DOS Prompt)
  • Then do the following, which quickly edits the 19 or so files, using Perl - the important lines are in bold.
  • Type the Perl line very carefully
    • If you do mis-type the perl line, you can restore from the .backup directory and re-run the command, as it will only edit the original files, not the backups with '~' suffixes.

$ cd /twiki/bin

$ ls
attach   geturl         oops     rdiff     save        testenv  viewfile
changes  installpasswd  passwd   register  search      upload
edit     mailnotify     preview  rename    statistics  view

$ mkdir .backup 
$ cp * .backup

$ head -1 view
#!/usr/bin/perl -wT

$ perl -pi~ -e 's;#!/usr/bin/perl;#!c:/cygwin/bin/perl;' *[a-z]

$ head -1 view
#!c:/cygwin/bin/perl -wT

$ ls
attach    geturl          oops      rdiff      save         testenv   viewfile~
attach~   geturl~         oops~     rdiff~     save~        testenv~  view~
changes   installpasswd   passwd    register   search       upload
changes~  installpasswd~  passwd~   register~  search~      upload~
edit      mailnotify      preview   rename     statistics   view
edit~     mailnotify~     preview~  rename~    statistics~  viewfile

If for some reason the edit goes wrong, just type cp .backup/* . (while within the bin directory) to restore the original distribution files. Use ls -a to see the .backup directory, and ls -a .backup to view its contents.

Optional step: you can do 'rm -f *~' to clean out the backups made by Perl, but that's not essential as all the original files cannot be executed. If you do this, type the command very carefully, as a space after the '*' will wipe out all files in this directory!

6. Minor changes to TWiki scripts

Perl module installation

7. Installing required Perl modules

* NOTE: Before you start this section, make sure you have installed the Cygwin make and gcc packages, which are used by the CPAN installer (gcc is required for modules that include C language code). Look in cygwin\bin for the files names make and gcc. If they are not there, install them now by launching Cygwin's setup.exe from c:/download/cygwin-dist and selecting them in the same way you did the other Cygwin modules.

Some other Perl modules are needed, in addition to the standard modules that are installed with Cygwin. Fortunately, there is an automated tool called cpan that makes installing these modules easy to do. This tool goes to the Perl module archive site, http://d8ngmj92uuzx6zm5.roads-uae.org/, downloads each module that you request, and then builds and installs it.

Note: if you are unable to get cpan working in your environment, don't panic; you can still install the modules manually. In this case, follow the instructions in CPAN: The Manual Way.

First, you need to install and configure the cpan tool. You only have to do this once. From the Cygwin shell, type the following:

$ export TEMP=/c/temp
$ cpan

Note: Putting the export TEMP=/c/temp command into ~/.profile in cygwin/etc is recommended to make this setting persistent. If you do not make it persistent, you have to type the command every time you want to use cpan. Without the TEMP variable, some modules may fail to install on Windows 2000 or XP and higher.

You will be asked many questions about configuration and preferences - just press Enter to accept the defaults until you get to the questions about mirror sites. If you are behind a proxy-based firewall, also answer the questions about FTP proxies. The CPAN tool will fetch a series of files, some quite large, as part of this setup process, so be patient...

NOTE: If you are behind a non-proxy-based firewall that requires the use of passive FTP, the initial file downloads by Net::FTP may appear to hang - just wait 5 or more minutes and the CPAN tool should eventually start using ncftpget, which is part of Cygwin and works behind a firewall. If this doesn't work and you are behind a typical NAT-based firewall, try typing the following at the Cygwin shell before running cpan - to force Net::FTP to use passive FTP, letting it get through such firewalls:

$ export FTP_PASSIVE=1

If this works, add this line, export FTP_PASSIVE=1 to your ~/.profile file for future use.

After some files have been downloaded, you will be asked to select your continent, your country, and then one or more mirror sites - just type the number of the mirror sites you want to use (pick a few in case one is down):

...
(28) Turkey
(29) Ukraine
(30) United Kingdom

Select your country (or several nearby countries) [] 30

(1) ftp://cpan.teleglobe.net/pub/CPAN
(2) ftp://ftp.clockerz.net/pub/CPAN/
(3) ftp://ftp.demon.co.uk/pub/CPAN/
(4) ftp://ftp.flirble.org/pub/languages/perl/CPAN/
(5) ftp://ftp.mirror.ac.uk/sites/ftp.funet.fi/pub/languages/perl/CPAN/
(6) ftp://ftp.plig.org/pub/CPAN/
(7) ftp://mirror.uklinux.net/pub/CPAN/
(8) ftp://sunsite.doc.ic.ac.uk/packages/CPAN/
(9) ftp://usit.shef.ac.uk/pub/packages/CPAN/
Select as many URLs as you like,
put them on one line, separated by blanks [] 4 7 8

Enter another URL or RETURN to quit: []
New set of picks:
  ftp://ftp.flirble.org/pub/languages/perl/CPAN/
  ftp://mirror.uklinux.net/pub/CPAN/
  ftp://sunsite.doc.ic.ac.uk/packages/CPAN/

Eventually, you will see the cpan installer's shell prompt, >cpan, which means you are now ready to install a few modules - the tool will do all the work for you.

cpan> install Net::SMTP

This may already be installed. If it is, try 'force install', since it's useful to be able to set firewall and passive FTP configuration when using Net::FTP. Make sure you answer 'Y' to the question about whether you want to configure this package.

cpan> install Digest::SHA1
You will see text scrolling by on the screen as cpan finds, builds and installs the module. Watch for any errors, although it should work if you have installed the Cygwin packages listed above (particularly 'gcc' and 'make').

cpan> install MIME::Base64
This may already be installed.

After you have installed the Perl modules given above, you can exit the cpan prompt (with the quit command) and paste this URL into your browser:

http://f2t57d1uwnc0.roads-uae.org/bin/testenv

If the installation and configuration is correct, a page full of information about the Apache server, Perl and the wiki will open. Find the section called "Required Perl modules" and try to install each one with cpan to make sure they are all installed.

CPAN: The Manual Way

If you find that cpan doesn't work for you, perhaps because you are behind an uncooperative corporate firewall, you may have to install the modules manually. In this case, you need to read the CPAN INSTALL page and visit the CPAN search site to search for each module. Search for the name shown below, and download the module.

Net::SMTP
Digest::SHA1
MIME::Base64

Usually installation involves downloading the module distribution into a temporary directory and unpacking it (a .tar.gz or .tgz file is unpacked using tar zxvf file). Then type the following:

$ perl Makefile.PL
$ make
$ make test
$ make install
The make test step should not be skipped - for example, one known problem is with the Digest::SHA1 module on Windows NT, which does not pass its tests and does not work. This causes problems with password encoding. In this event you can use another encoding scheme or switch to unencoded passwords. There may be other problems on the various Windows configurations, and you can save yourself a lot of time by running the tests.

Re-locking RCS files

8. Re-locking files

First, some testing: in your browser, go to http://f2t57d1uwnc0.roads-uae.org/bin/testenv - this provides a lot of detail, including warnings. Write down the Apache server's userid that is given by this script - typically either 'system' or 'administrator' - I'll assume 'system' from now on.

  • If the testenv script doesn't work, go back and check the configuration of the Apache httpd.conf file, and TWiki.cfg. Have a look at the Apache error log, c:/apache/logs/error_log, and the TWiki error log, /twiki/data/log*.txt.

This user named 'system' must own the locks on the RCS files, which are shipped with the lock held by 'nobody'. Revisions cannot be tracked by RCS unless the Apache userid matches that of the RCS file locks.

If you don't want to preserve the revision history and old versions of the files that shipped with the Twiki, the easiest way to reset the locks is to use the Windows file manager to delete the locked RCS files. Open the /twiki/data directory and delete all files that end with ".txt,v~" (the revisions will have one or more "~" symbols in the name). All new revisions will be created with the correct user automatically owning the locks. The only flaw with this method is that the wiki pages will show the old revision numbers until you edit and save them.

You can re-lock files using rcs -u and rcs -l, but it's a painfully manual process. Instead, just use Perl again to mass-edit all the RCS files, as follows:

  • NOTE: The 'NR <= 10' part of the Perl command ensures that it only operates on the first 10 lines, to avoid editing the body of RCS files for topics that happen to include the text 'nobody:' (like this one...)

$ cd /twiki/data

$ : Make a backup of all files
$ tar czvf all-files.tar.gz */*

$ : Test edit a single file to check your typing
$ perl -pi~~~ -e 'NR <= 10 && s/nobody:/system:/ ' Main/WebIndex.txt,v

$ diff Main/WebIndex.txt,v Main/WebIndex.txt,v~~~
5c5
<       system:1.2; strict;
---
>       nobody:1.2; strict;

$ : Now edit all the RCS files at once - use cursor-up to recall previous command
$ perl -pi~~~ -e 'NR <= 10 && s/nobody:/system:/ ' */*,v

$ : Check for any files not edited properly - should not produce any output
$ grep 'strict;$' */*,v | grep nobody

$ : Clean up - type this very carefully as a single typo could remove a large number of the wrong files 
$ rm -f */*~~~

  • If something goes wrong: to restore your existing files from the backup, just type tar xzvf all-files.tar.gz and all your files, both .txt and .txt,v, will be back as they were before the edits.

You have now re-locked all the RCS files and are almost ready to start using TWiki!

Edit Configuration Files and Set File Permissions

9. Edit Configuration Files

Note - you may need to change the permissions on the configuration files so that you can edit them. Do that in the most convenient way: we're going to set their permissions correctly for operation in a subsequent step, so don't worry about exactly what permissions you give them just for editing purposes.

  • Security setup: Secure your TWiki data, lib and templates directories.
    • Directories twiki/data, twiki/lib, twiki/templates and all their subdirectories should be configured in your Apache server so that they are *not* visible through URLs.
    • There is subdir-htaccess.txt under twiki installation directory. Copy it into the data, lib and templates subdirectories, naming it .htaccess to have Apache recognize it. Or you may edit the Apache http.conf file to set deny from all there (this is recommended by Apache.org)
    • Alternatively, move the directories to a place where they are not visible, and change the variables in twiki/lib/TWiki.cfg accordingly.

10. Set File Permissions

For the following configuration use the cygwin shell.

  • Set the file permission of all Perl scripts in the twiki/bin directory as executable to -rwxr-xr-x (755). Use the chmod command (that is: chmod 755 directoryname ).
  • To be able to edit the Perl scripts and .tmpl files it is necessary to chown and chgrp -R twiki so all the files have the owner you want (that is: chown newowner file and chgrp newgroup file ).
  • HELP This Guide assumes user SYSTEM ownership for all files manipulated by the CGI scripts (executed by the Web server), and user twiki for all other files. You can:
    • replace SYSTEM with another user if your web server executes scripts under a different name.
    • TIP HINT: Run the testenv script from your browser: http://f2t57d1uwnc0.roads-uae.org/twiki/bin/testenv. It will show you the user name of the CGI scripts ("LOGNAME: ..."), a table listing all CGI environment variables, and a test of your twiki/lib/TWiki.cfg configuration file.
    • replace user twiki with your own username

  • Set permissions manually.
    • Set the permission of all files below twiki/data so that they are writable by user SYSTEM. A simple way is to chmod them to -rw-rw-r-- (that is: chmod 664 filename ) and to chown them to SYSTEM.
    • Set the permission of the twiki/data directory and its subdirectories so that files in there are writable by user SYSTEM. A simple way is to chmod them to drwxrwxr-x (775) and to chown them to SYSTEM.
    • Set the permission of the twiki/pub directory and all its subdirectories so that files in there are writable by user SYSTEM. A simple way is to chmod them to drwxrwxr-x (775) and to chown them to SYSTEM.

Email setup

11. Email setup for notification and registration

You need to set the SMTPMAILHOST in TWikiPreferences to an SMTP email host that is reachable and currently working. Otherwise you may get a confusing message from TWiki (fixed in TWiki:Codev.TWikiRelease01Feb2003) when registering new users or running mailnotify (for WebNotify), along the lines of:

   Software Error: Can't call method "mail" on an undefined value at ../lib/TWiki/Net.pm line 187.

There are other settings to be made in TWikiPreferences, e.g. the WIKIWEBMASTER and (probably) the SMTPSENDERHOST (normally your mail server or TWiki server). See the TWikiInstallationGuide for more details, what's listed here is just enough to let you run the basic tests.

Testing your TWiki installation

It is important to test your TWiki installation before you release it to other users or put any significant data into it.

Here are the main things to test:

  • testenv - use http://f2t57d1uwnc0.roads-uae.org/bin/testenv and check for warnings
  • Page viewing (view script) - click around a few pages and make sure the links are OK
  • RCS diffs (rdiff script) - click on the Diffs link and on the '>' links at bottom of page
  • Edit a page, and register as a new user - tests page creation, use of register script to create a new user entry in /twiki/data/.htpasswd (the Apache password file), ability to send email via Net::SMTP, and whether SMTPMAILHOST was set correctly in TWikiPreferences (if it is unset it will not use Net::SMTP and will almost inevitably fail silently).
    • If you get a failure to register or send email, check the Apache error log, and that all CPAN modules were installed correctly in Step 6, Installing required Perl modules.
    • Try typing tail -30 /c/apache/logs/error_log to see last 30 errors from Apache
  • Edit a page - check revision increased and set to current date/time
  • Edit the same page using another browser or PC, logging in as a different user - check there's a lock message (which you can override) and no double lines
  • Check the Apache error_log file to see if there are any RCS errors so far
  • Index - tests whether ls and grep are working
  • Search - more tests for whether ls and grep are working
  • Attachments - tests access to /twiki/pub directory.
    • Try a binary attachment upload and check the number of bytes in the file has not changed - if it has, see the Install Cygwin section's note on the default text file type.
  • Check the Apache error_log file again

Troubleshooting

If anything doesn't work, go back and check the configuration of the Apache httpd.conf file, and TWiki.cfg. Have a look at the Apache error log, c:/apache/logs/error_log, and the TWiki error log, /twiki/data/log*.txt, and if necessary enable debugging on selected scripts (the commands are right at the top of each script) - the results go into /twiki/data/debug.txt. There is also a /twiki/data/warning.txt file that contains less serious messages.

See TWiki:Codev.TWikiPatches in case there are patches (i.e. specific code changes) for particular problems that may affect you (e.g. TWiki:Codev.ChangePasswordOnWin2K).

If you find that the Index feature doesn't work, or topic name searches fail, you should check you have set $egrepCmd and $fgrepCmd correctly, as mentioned above.

Permissions

TWiki:Codev.CygWin has several models for how it does security:

  • By default, it only implements the Unix 'write' and 'execute' permissions bits - the former is controlled by the Windows Read-Only attribute, while the latter is automatically assigned to files named *.exe or *.com, and to files whose first line is a shebang (i.e. #!/bin/something). This is what has been used for this cookbook.
  • You can enable the 'ntea' or 'ntsec' models, which will increase security but are also likely to introduce permission problems.

I have not had any problems with TWiki permissions on Windows, unlike Linux/Unix, which is probably because I'm using the default security model for Cygwin. If you use the other models, you may still be OK if you have local admin rights, and Apache is running as the SYSTEM user (which it uses if started as a service). If you do have trouble in this area, see the TWikiInstallationGuide's advice, some of which will apply to TWiki:Codev.CygWin, and log any issues in TWiki:Codev.WindowsInstallCookbookComments.

Next Steps

See the TWikiInstallationGuide for other setup. In particular, you'll probably want to refer to the section on basic authentication - remember to use c:/twiki type filenames (i.e. Windows format) since you are using Apache for Windows.

Improved authentication

You may want to investigate TWiki:Codev.WindowsInstallModNTLM and ModAuthSSPICookbook, which describes how to add an Apache module so that TWiki:Codev.InternetExplorer users are automatically authenticated based on their Windows domain login - this avoids TWiki:Codev.GettingTheUsernameWrong and TWiki:Codev.ForgettingPasswords, which are usually very common among TWiki users.

As of the TWiki:Codev.TWikiRelease01Sep2004, there is built in support for several apache based authentication modes. The TWikiInstallationGuide has step-by-step instructions.

Improved performance

See TWiki:Codev.WindowsModPerlInstallCookbook and TWiki:Codev.ModPerl for information on installing TWiki under Apache's mod_perl - this is somewhat more complex and follows a different model, so it's best to get some experience with TWiki, Apache and Perl first.

Format of filenames

In your TWiki on Windows installation, it's worth remembering that:

  • Apache configuration files (e.g. the .htaccess file and c:/apache/conf/httpd.conf) always use Windows format paths, with forward slashes, e.g. c:/twiki
  • The same is true for the first line of the TWiki Perl scripts (since this line is interpreted by Apache), e.g. c:/cygwin/bin/perl
  • All other lines in the Perl scripts use Unix format paths, e.g. /twiki (using Cygwin Perl as per this cookbook)
  • Depending on the Perl version used (Cygwin or TWiki:Codev.ActivePerl), the TWiki.cfg file uses a mixture of Unix and Cygwin format paths - stick to the format used in the installation step for TWiki.cfg
  • RCS always uses Unix format paths, e.g. /twiki

Credits

Material in this cookbook is heavily based on the enormous number of contributions in TWiki:Codev.TWikiOnWindowsArchive and related topics - too many people to thank, but have a look at the contributor list to TWiki:Codev.TWikiOnWindowsArchive to get an idea!

People who've tested or reviewed this document and provided valuable feedback include:

-- Contributors: TWiki:Main.BernardFarrell, TWiki:Main.BerndSchiffer, TWiki:Main.ChrisKeith, TWiki:Main.CrawfordCurrie, TWiki:Main.DavideBaroncelli, TWiki:Main.DavidLeBlanc, TWiki:Main.JerryWard, TWiki:Main.MartinWittmann, TWiki:Main.MaryDeMarco, TWiki:Main.MattWilkie, TWiki:Main.MikeBytnar, TWiki:Main.PeterThoeny, TWiki:Main.RossC, TWiki:Main.TorbenGB, TWiki:Main.VictorGoh, TWiki:Main.WolframJahn



Comments & Questions about this Supplemental Document Topic

ALERT! Comments welcome at TWiki:Codev.WindowsInstallCookbookComments

I restored the topic text from the previous version, the WysiwygPlugin cannot handle content on this topic well.

-- PeterThoeny - 09 Aug 2006

Edit | Attach | Watch | Print version | History: r67 < r66 < r65 < r64 < r63 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r67 - 2012-02-14 - PeterThoeny
 
  • 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-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.