## Please edit system and help pages ONLY in the master wiki!
## For more information, please see MoinMoin:MoinDev/Translation.
##master-page:Unknown-Page
##master-date:Unknown-Date
#acl -All:write Default
#format wiki
#language en
'''Index''' <<TableOfContents>>

== Requirements & Preparation ==
Before you install MoinMoin, make sure you have the necessary infrastructure in place, namely the ''Internet Information Services'' webserver (any version should be OK), and a ''Python'' installation (at least version 2.3 is required, the latest python release is recommended).

These instructions make the basic assumption that you will have these components installed in their default locations. In reality, you'll probably have them installed elsewhere (on the D: drive, for example). Be careful to substitute your drive and paths based on the following assumed default locations:

 * IIS to its default location
 * {{{C:\Python}}} - the Python interpreter
 * {{{C:\Moin}}} - !MoinMoin itself
== Installation ==
=== Installing IIS ===
From Microsoft: (http://www.microsoft.com/windows2000/en/server/iis/)

 1. To install IIS, add components, or remove components:
  i. Click Start => Settings => Control Panel => Add/Remove Programs.
  i. Click 'Add/Remove Windows Components', Check 'Internet Information Services' and follow the on-screen instructions to install. ( /!\ it is also recommended to click the 'details' button and un-selecting components you will not need. This will depend on your server role; but for example, you probably will not need FTP, or "Frontpage 2000 Server Extensions").
Make sure that your webserver runs without problems before you start to install !MoinMoin; problems with your webserver installation are not in the scope of this document.

=== Installing Python ===
There are currently two different distributions of Python available for Windows. Either version will work fine.

 1. http://www.python.org - The standard open-source Python distribution.
  * The installer is a windows executable (.exe) file.
 1. http://www.activestate.com - An alternative, commercially-supported, distribution (distributed for free (email address required)).
  * The installer is a Windows .MSI file.
  * If you are or plan to develop in the Python language, !ActivePython has some tools specific to the Windows operating system and includes a popular Windows IDE called Pythonwin.
!MoinMoin works with either distribution, but requires Python release 2.3 or later. Download and install the distribution of your choice. Be sure your Python installation is correct before proceeding. Installation is straightforward; however, any questions or issues regarding the Python installation process should be resolved through the use of resources provided by Python.org or !ActiveState.

=== Installing MoinMoin ===
 1. '''Download !MoinMoin'''
  * The most current version is here: MoinMoin:MoinMoinDownload
 1. '''Expand the archive'''
  * __''Note:''__ users of older versions of [[http://www.winzip.com|WinZip]] report problem expanding .tar.gz files. Either upgrade or use the free [[http://7-zip.org/|7-Zip]] utility.
  * Expand the archive into {{{C:\TEMP}}} or an alternative location.
  * You should then have a folder such as {{{C:\TEMP\moin-x.x}}} where "x.x" is the current release number. This folder will contain a {{{setup.py}}} file in addition to several other files and subfolders.
 1. '''Run Setup.py from the commandline'''
  * Open an DOS window (start > Run... > type {{{cmd}}}) and enter the commands:<<BR>>
  {{{
C:
cd \temp
unzip moin-1.6.zip
cd moin-1.6
python setup.py install --prefix=C:\Moin --record=install.log
}}}
This will install all necessary files to the "{{{C:\Moin}}}" directory, and create a "{{{install.log}}}" file listing all the files that are created there.

You are now ready to create a wiki instance.

== Configuration ==
=== Creating a Wiki Instance ===
Enter these commands in a console window from C:\Moin>:

{{{
cd c:\Moin
md mywiki
md mywiki\data
md mywiki\underlay
xcopy share\moin\data mywiki\data /E
xcopy share\moin\underlay mywiki\underlay /E
copy share\moin\server\moin.cgi mywiki\
copy share\moin\config\wikiconfig.py mywiki\
copy share\moin\htdocs\index.html mywiki\default.htm
}}}
"{{{mywiki}}}" is the name of your wiki instance, you might want to chose a different name best fitting the intended use of this instance; just don't name it simply "{{{wiki}}}", because that would result in confusion and problems later on.

We have to make sure that {{{moin.cgi}}} can find the !MoinMoin directory, so that "{{{import MoinMoin}}}" will work. The easiest way to make sure {{{MoinMoin}}} can be imported is to append to {{{sys.path}}} ''within'' {{{moin.cgi}}}.

You can change the first two lines of code in moin.cgi to something like this:

{{{
#!python
#!python
import sys
sys.path.append('C:/Moin/Lib/site-packages')
}}}
Notice that we're pointing to the directory which contains the !MoinMoin directory, not the directory itself.

=== Configuring IIS ===
Next, you'll need to create two virtual directories in IIS. One for the shared data, and one for this specific wiki instance.

==== Configuring IIS 5.0 and above ====
 1. Open '''Internet Services Manager''' (Start > Settings > Control Panels > Administrative Tools > ...). Open up the tree to ''Default Web Site''.

 1. Right click on ''Default Web Site'' and choose ''New > Virtual directory''.
  i. This will bring up a wizard with the mandatory useless first screen, hit next.
  i. Enter "{{{wiki}}}" for the alias name, hit next.
  i. Browse to "{{{C:\Moin\share\moin\htdocs}}}", hit next.
  i. Leave the ''Access permissions'' at their defaults, hit next.
  i. And now you're done, hit finish!

 1. Now follow the same steps, but set the alias to "{{{mywiki}}}" and the path to "{{{C:\Moin\mywiki}}}".

 1. Use IIS Admin to remove permissions to read the data directory:
  i. expand the "{{{mywiki}}}" node
  i. right click on {{{data}}}
  i. select {{{Properties}}}
  i. and uncheck {{{Read}}}.
  i. Repeat these steps with the {{{underlay}}} directory.

 1. Now you need to setup the 'mywiki' alias so that it will run Python to interpret {{{.cgi}}} files.
  i. On Windows Server 2003, click the ''Create'' button under ''Application Settings'' to create an application space.

  i. Right-click on your new 'mywiki' alias and choose ''Properties''. On the first tab (''Virtual Directory''), click the ''Configuration'' button.

  i. The first tab is the ''App Mappings'' tab, which defines which programs to use for each file extension.

  i. Click ''Add''. Browse to your {{{python.exe}}} (probably something like {{{c:\pythonXX\python.exe}}}).

  i. Then add {{{-u "%s" "%s"}}} after the Python executable path. The ''Executable'' line will look something like this: {{{"C:\Python22\python.exe" -u "%s" "%s"}}}. In the ''Extension'' box enter {{{.cgi}}} with the beginning period.

  i. Make sure that the ''Check that file exists'' option is not checked (if it is, !MoinMoin won't be able to display sub pages).

  i. Ok, you're done with the alias configuration, click ''OK'' several times to get back out of all the dialog boxes.

 1. If you add another wiki instance, you'll only need to setup the reference to its folder, they can safely share the "{{{wiki}}}" alias which points to static files only.
==== IIS 6.0 (Windows Server 2003) ====
The instructions below also apply to IIS 6.0 but the more aggressive security settings in newer version of IIS disallow the usage of ''unknown CGI extensions''. That means you will always get a 404 error unless you do this:

 1. Open '''IIS Manager''' (Start > Programs > Administrative Tools > IIS Manager).

 1. Go to the '''Web Service Extensions''' folder.

 1. Under the '''Action''' menu, select '''Add a new Web service extension...'''.

 1. For Extension name, give it a name such as ''.cgi'' or ''Python cgi'' or similar.

 1. Under '''Required files''' click the '''Add...''' button and type in the exact command-line string you used above. Eg: {{{c:\python24\python.exe -u "%s" "%s"}}}, then click the '''Ok''' button.

 1. Make sure the '''Set extension status to Allowed''' checkbox is checked and click the '''Ok''' button.
Another change that may be necessary if you are receiving HTTP Error 403 19 1314 while using IIS 6.0 is to adjust the Identity settings for the Application Pool that is being used by your site. The following steps assume you are adjusting the Default Web Site.

 1. Open '''IIS Manager''' (Start > Programs > Administrative Tools > IIS Manager).

 1. Go to the '''Application Pool''' folder.

 1. Select the Application Pool you wish to adjust. (likely '''!DefaultAppPool''' ) When you do this on the right you will see the Application pools for each site on the server. This will include a Description (likely '''Default Application''' ) and a Path ('''<Default Web Site>'''). In this way you can be certain you are adjusting the appropriate Application Pool.

 1. With '''!DefaultAppPool''' still selected right click and select '''Properties'''.

 1. Select the '''Identity''' tab and with '''Predefined''' clicked use the drop down box to change the '''Identity''' to '''Local System''' instead of Network Service. ''Please be aware that this is a workaround since you SHOULD set your group settings to allow Network Service to access the cgi scripts.''
Under Windows Server 2003, you will also need to give your IUSR_MACHINENAME account ''Modify'' access to the mywiki\data and mywiki\underlay sub-directories, as file system permissions are more restricted by default than previous Windows versions.

That is all, try to access your new-born wiki with the URL http://127.0.0.1/mywiki/. You should see the !FrontPage, try to edit and save it, and if that works, see if your edit is reflected on the !RecentChanges page.

=== Configuring wikiconfig.py ===
Finally, edit "{{{wikiconfig.py}}}" and at least change "{{{sitename}}}" and "{{{logo_string}}}" to some personal values:

{{{
sitename = u'My Wiki'
logo_string = u'<img src="/mywiki/images/mywiki-logo.gif" alt="MyWiki Logo">My Wiki'
}}}
Where "{{{images}}}" is a directory under your "{{{mywiki}}}" instance.

NOTE: The configuration variable "{{{url_prefix}}}" in "{{{wikiconfig.py}}}" should match the alias for "{{{C:\Moin\share\moin\htdocs}}}" or themes will not work ("{{{/wiki}}}" for the instructions above). This way, any reference in "{{{wikiconfig.py}}}" to "{{{/wiki/something}}}" will look in the shared data directory and a reference to "{{{/mywiki/something}}}" will look in the wiki instance directory. These are considered absolute paths because relative paths will not work correctly.

It seems you need to change the Custom Errors setting for 404 before you can create new pages. You can accomplish this by performing the following steps:

 1. Go into the IIS Manager, right-click on 'mywiki' (or whatever your wiki instance directory is called), and select properties.

 1. Next, go to the Custom Errors tab and find the 404 entry, and click the ''Set to Default'' button.
== Troubleshooting ==
 * If you see an error like "{{{ImportError: No module named MoinMoin}}}", it means that python cannot find Moin``Moin. See above for how to add to {{{sys.path}}}.
 * If you see an error like Error 13: Permission Denied, it means that your web user permissions for the files do not have write/modify enabled.
 * If the page never loads after hitting {{{Save Changes}}}, you should check the permissions of the {{{data}}} directory. Make sure the IUSR_COMPUTERNAME user has modify permissions.
 * If some images like !InterWiki and !WorldWideWeb don't show up, it could have been because of incorrect permissions or a bad "{{{url_prefix}}}" in "{{{wikiconfig.py}}}" or the cached pages need to be updated by an Edit or deleting them in the data folder. Or you are using MS IE which has broken CSS :before support - try another browser.
 * If you see an error message like:<<BR>>
 {{{
Check your URL regular expressions in the "wikis" list in "farmconfig.py". Content-type: text/html;charset=utf-8
MoinMoin Configuration Error
Could not find a match for url: "servername/wikiname/moin.cgi?
Check your URL regular expressions in the "wikis" list in "farmconfig.py".
}}}
  and you don't intend on using a serverfarm, remove the farmconfig.py and farmconfig.pyc files and try again. The error message shouldn't appear when you refresh the page.


==== IIS URLScan problem ====
If you see an error like "''The system cannot find the file specified.''" when trying to run Moin on IIS the problem may be URLScan.  By default URLScan blocks any URLs that use PATH_INFO.  To solve the problem, edit the URLScan.ini file in the {{{%SystemRoot%\system32\inetsrv\urlscan\urlscan.ini}}} directory.  I changed the line allowdotinpath from 0 to 1.  As follows

{{{
allowdotinpath=1               ; if 1, allow dots that are not file extensions
}}}

Also, you might have to add the following setting: {{{
[options]
AllowHighBitCharacters=1
}}}

Next save the URLScan.ini and then restart the IIS service.  Your wiki should now work.

For more information, please reference the Microsoft article [[http://support.microsoft.com/default.aspx?scid=kb;en-us;Q326444| How to configure the URLScan tool]]

== Next Steps ==
 * Backing up !MoinMoin is simple. Look at HelpOnInstalling/Win32MoinEasyBackup for guidance (despite the somewhat misleading title, the procedure would be the same for IIS).
