%META:TOPICINFO{author="PeterThoeny" date="1044149369" format="1.0" version="1.53"}%
%TOC%
%STARTINCLUDE%
---# TWiki Installation Guide

_Installation instructions for the TWiki 01-Feb-2003 production release. Update notes for the new RCS configuration are marked_ __Dataframework__.

These installation steps are based on the *Apache* web server on *Linux*. TWiki runs on other web servers and Unix systems, and should be fine with any web server and OS that meet the [[TWikiSystemRequirements][system requirements]]. Documentation for other platforms is somewhat limited:

	* For Unix or Linux, check TWiki:Codev/TWikiOnUnix and TWiki:Codev/TWikiOnLinux.
	* For Windows, check the WindowsInstallCookbook. 
	* For <nop>MacOS X, check TWiki:Codev/TWikiOnMacOSX. 
	* To install TWiki on <nop>SourceForge, for use on a software development project, read TWiki:Codev/TWikiOnSourceForge
	* For other platforms, see TWiki:Codev/TWikiOn, and search the TWiki:Codev and TWiki:Support webs for other installation notes.

#StandardInstallation
---++ Standard Installation

Request and download the TWiki 01-Feb-2003 distribution in Unix ZIP format from http://TWiki.org/download.html. Please review the AdminSkillsAssumptions before you install TWiki.

---+++ Step 1: Create &amp; Configure the Directories

%X% *NOTE:* _If you don't have access to your Web server configuration files - for example, if you're installing on an ISP-hosted account, or you don't have administrator privileges on your intranet server - use the [[#StepOneB][alternative Step 1]] instead._

	* Create directory =/home/httpd/twiki= and [[http://www.info-zip.org/pub/infozip/UnZip.html][unzip]] the TWiki distribution into this directory.
	* The =twiki/bin= directory of TWiki must be set as a cgi-bin directory. Add =/home/httpd/twiki/bin= to file =/etc/httpd/httpd.conf= with only =ExecCGI= option.
	* The =twiki/pub= directory of TWiki must be set so that it is visible as a URL. Add =/home/httpd/twiki= to file =httpd.conf= with normal access options (copy from =/home/httpd/html= ).
	* Now add =ScriptAlias= for =/twiki/bin= and =Alias= for =/twiki= to file =httpd.conf= .
	  <br /> %X% *NOTE:* The =ScriptAlias= __must__ come before the =Alias=, otherwise, Apache will fail to correctly set up =/twiki/bin/=, by treating it as just another subdirectory of the =/twiki/= alias.
	* The =twiki/data= and =twiki/templates= directories should be set so that they are *not* visible as URLs. Add them to =httpd.conf= with =deny from all=.

<blockquote style="background-color:#F5F5F5">
*Example =httpd.conf= entries:*
 <pre> Script<nop>Alias /twiki/bin/ "/home/httpd/twiki/bin/"
 Alias /twiki/ "/home/httpd/twiki/"
 &lt;Directory "/home/httpd/twiki/bin"&gt;
	 Options +ExecCGI
	 Set<nop>Handler cgi-script
	 Allow from all
 &lt;/Directory&gt;
 &lt;Directory "/home/httpd/twiki/pub"&gt;
	 Options Follow<nop>Sym<nop>Links +Includes
	 Allow<nop>Override None
	 Allow from all
 &lt;/Directory&gt;
 &lt;Directory "/home/httpd/twiki/data"&gt;
	 deny from all
 &lt;/Directory&gt;
 &lt;Directory "/home/httpd/twiki/templates"&gt;
	 deny from all
 &lt;/Directory&gt;</pre>
</blockquote>

	* Restart Apache by =/etc/rc.d/rc5.d/S85httpd restart= .
	* Test that the =twiki/bin= directory is CGI-enabled by trying visiting it in your browser:
		* Enter the URL for the =bin= directory, =http://yourdomain.com/twiki/bin/=.
		* Your settings are OK if you get a message like ="Forbidden. You don't have permission to access /twiki/bin/ on this server"=.
		* Settings are NOT correct if you get something like ="Index of /twiki/bin"= - recheck your =httpd.conf= file. 

	* _Go directly to [[#StepTwo][Step 2]]..._

#StepOneB		  
---++++ Step 1 for Non-Root Accounts

To install TWiki on a system where you don't have Unix/Linux root (administrator) privileges, for example, on a hosted Web account or an intranet server administered by someone else: 

	* Download and unzip TWiki on your local PC
	* Using the table below, create a directory structure on your host server
	* Upload the TWiki files by FTP (transfer as _text_ except for the image files in =pub=)
<blockquote>
| *TWiki dir:* | *What it is:* | *Where to copy:* | *Example:* |
| =twiki= | start-up pages | root TWiki dir | =/home/smith/twiki/= |
| =twiki/bin= | CGI bin | CGI-enabled dir | =/home/smith/twiki/bin= |
| =twiki/lib= | library files | same level as =twiki/bin= | =/home/smith/twiki/lib= |
| =twiki/pub= | public files | htdoc enabled dir | =/home/smith/twiki/pub= |
| =twiki/data= | topic data | dir secure from public access | =/home/smith/twiki/data= |
| =twiki/templates= | web templates | dir secure from public access | =/home/smith/twiki/templates= |
</blockquote>

If you are not able to create the =twiki/lib= directory at the same level as the =twiki/bin= directory (e.g. because CGI =bin= directories can't be under your home directory and you don't have root access), you can create this directory elsewhere and edit the =setlib.cfg= file in the =bin= directory:

<pre>
	 # -------------- Change these settings if required

	 $twikiLibPath = <font color="red">'/some/other/path/lib'</font>;	# Path to lib directory containing TWiki.pm

</pre>

You can also edit =$localPerlLibPath= in the =setlib.cfg= file if you are not root and need to install additional CPAN modules, but can't update the main Perl installation files on the server.  Just set this variable to the full pathname to your local lib directory, typically under your home directory. 

#StepTwo
---+++ Step 2: Set File Permissions

	* Make sure Perl 5 and the Perl CGI library are installed on your system. The default location of Perl is =/usr/bin/perl=. If it's elsewhere, change the path to Perl in the first line of each script in the =twiki/bin= directory, or create a symbolic link from =/usr/bin/perl=.
		* *IMPORTANT:* On ISP-hosted accounts, Perl CGI scripts usually require a =.cgi= extension to run. Some systems need =.pl=, the regular Perl extension. Modify all =twiki/bin= script filenames if necessary.
	* Set the file permission of all Perl scripts in the =twiki/bin= directory as executable to =-rwxr-xr-x= (755).
	* 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.
	* %H% This Guide assumes user =nobody= ownership for all files manipulated by the CGI scripts (executed by the Web server), and user =twiki= for all other files. You can: 
		* replace =nobody= with another user if your server executes scripts under a different name (ex: default for Debian is =www-data=).
			* %T% *HINT:* Run the =testenv= script from your browser: =http://yourdomain.com/twiki/bin/testenv=. It will show you the user name of the CGI scripts, a table listing all CGI environment variables, and a test of your =twiki/lib/TWiki.cfg= configuration file (you'll configure that in a minute).
		* replace user =twiki= with your own username
	* Set the permission of all files below =twiki/data= so that they are writable by user =nobody=. A simple way is to =chmod= them to =-rw-rw-r--= (664) and to =chown= them to =nobody=.
	* Set the permission of the =twiki/data= directory and its subdirectories so that files in there are writable by user =nobody=. A simple way is to chmod them to =drwxrwxr-x= (775) and to =chown= them to =nobody=.
	* Set the permission of the =twiki/pub= directory and all its subdirectories so that files in there are writable by user =nobody=. A simple way is to =chmod= them to =drwxrwxr-x= (775) and to =chown= them to =nobody=.
	* %H% The =twiki/data/*/*.txt,v= RCS repository files in the installation package are locked by user =nobody=. If your CGI scripts are __not__ running as user =nobody=, it's not possible to check in files (you'll see that the revision number won't increase after saving a topic). In this case, you need to unlock all repository files (check the RCS man pages) and lock them with a different user, ex =www-data=, or delete them all - new files will be automatically created the first time each topic is edited. A simple way to change ownership is with a search-and-replace in all files; for example, using perl:
<blockquote style="background-color:#F5F5F5">
<pre>
cd twiki/data
perl -pi~ -e 's/nobody:/www-data:/' */*,v
</pre>
</blockquote>

---+++ Step 3: Set the Main Configuration File

	* Edit the file =twiki/lib/TWiki.cfg=, setting the variables to your needs.
		* Set the file extension in the =$scriptSuffix= variable to =cgi= or =pl= if required.
		* RCS - revision control system to store revision of topics and attachments.  You can use RCS executables or a version of RCS written in Perl, note that as the time of writing (Apr 2002) the Perl version has not been widely tested, so if you want to put up a live site the RCS executables are recommended. 
			* Set <code>$storeTopicImpl = "RcsWrap";</code> for the RCS executables and make sure RCS is installed. Set =$rcsDir= in =twiki/lib/TWiki.cfg= to match the location of your RCS binaries. You can check this by issuing the command =rcs= at the prompt, it should result in something like ="rcs: no input file"=.  
				* Check that you have GNU =diff=, by typing =diff -v= - an error indicates you have a non-GNU diff, so install the GNU =diffutils= package and make sure that =diff= is on the PATH used by TWiki (see =$safeEnvPath= in the =TWiki.cfg= file).
			* Set <code>$storeTopicImpl = "RcsLite";</code> for the Perl based RCS
	* *Security issue:* Directories =twiki/data= , =twiki/templates= and all their subdirectories should be set so that they are __not__ visible through URLs. (Alternatively, move the directories to a place where they are not visible, and change the variables in =twiki/lib/TWiki.cfg= accordingly)
	* Test your settings by running the =testenv= script from your browser: =http://yourdomain.com/twiki/bin/testenv=. Check if your =twiki/lib/TWiki.cfg= configuration file settings are correct.


---+++ Step 4: Configure Site-Wide Email Preferences

	* From your web browser, edit the TWikiPreferences topic in the TWiki:%TWIKIWEB% web to set the =WIKIWEBMASTER= email address, and other email settings required for registration and WebChangesAlert to work:
		* =WIKIWEBMASTER= should be set to the email address of the TWiki administrator
		* =SMTPMAILHOST= is typically set on Windows or other non-Unix/Linux systems, where =sendmail= or similar is not available.  When this is set and the Perl module ==Net::SMTP== is installed, TWiki will connect to this SMTP server (e.g. =mail.yourdomain.com=) to send email for user registration and WebChangesAlerts.  If you do have a sendmail-type program, leave =SMTPMAILHOST= unset so that the external sendmail program is used instead (defined by ==$mailProgram== in ==TWiki.cfg==).
		* =SMTPSENDERHOST= is optional, and set to the domain name sending the email (e.g. =twiki.yourdomain.com=). For use where the SMTP server requires that you identify the TWiki server sending mail. If not set, ==Net::SMTP== will guess it for you. 
	* You may want to set up other TWikiPreferences later on.

---+++ Step 5: Finish Up from Your Browser

	* Point your Web browser at =http://yourdomain.com/twiki/bin/view= and start TWiki-ing away!
		* %T% Or, point to =http://yourdomain.com/twiki/= to get the pre-TWiki =index.html= page, with a link to the =view= script. Customize this page if you want a public intro screen with a login link, instead of immediately calling up the .htaccess login dialog by going directly to =view=.
	* Edit the WebPreferences topic in each web, if necessary: set individual =WEBCOPYRIGHT= messages, and other preferences.
	* Enable email notification of topic changes, TWikiSiteTools has more. 
	* Edit the WebNotify topic in all webs and add the users you want to notify.
	* Add the TWiki:Main/PoweredByTWikiLogo to your %MAINWEB%.WebHome topic.
	* You can add new =%<nop>VARIABLES%=. Define site-level variables in the TWikiPreferences topic. See also: TWikiVariables.

That's it for the standard virgin installation of TWiki. Read on for server-level customization options.
		
---++ Additional Server-Level Options

With your new TWiki installation up and running, you can manage most aspects of your site from the browser interface. Only a few functions require access to the server file system, via Telnet or FTP. You can make these server-level changes during installation, and at any time afterwards.

#AuthenticationOfUsers
---+++ Enabling Authentication of Users

	* If TWiki is installed on a non-authenticated server - not using SSL - and you'd like to authenticate users:
		1. *Rename* file =.htaccess.txt= in the =twiki/bin= directory to =.htaccess= and change it to your needs. For details, consult the HTTP server documentation (for Apache server: <a href="http://www.apache.org/docs/mod/directives.html">[1]</a>, <a href="http://www.mcs.kent.edu/system/web_help/htaccess/introduction.html">[2]</a>). In particular, the following <font color="red">red</font> part needs to be configured correctly: <br />
		 =Redirect <font color="red">/urlpathto/twiki/index.html</font> http<nop>://<font color="red">yourdomain.com/urlpathto/twiki/bin/</font>view= <br>
		  =AuthUserFile <font color="red">/filepathto/twiki/data/</font>.htpasswd= <br />
		  =ErrorDocument 401 <font color="red">/urlpathto/twiki/bin/</font>oops/TWiki/TWikiRegistration?template=oopsauth=
			* %X% *NOTE:* If you had to add a =.cgi= or =.pl= file extension to the =bin= scripts, make sure to do the same for =edit=, =view=, =preview=, and all the other script names in =.htaccess=. 
			* %H% The browser should ask for login name and password when you click on the <u>Edit</u> link. In case =.htaccess= does not have the desired effect, you need to enable it: Add "AllowOverride All" to the Directory <a href=http://httpd.apache.org/docs/mod/core.html#directory>[3]</a> section of =access.conf= for your =twiki/bin= directory. 
				* *This applies only if you have root access:* on hosted accounts, you shouldn't have this problem - otherwise, email tech support.
			* %X% *NOTE:* In the TWiki distribution package, the =twiki/data/.htpasswd.txt= file contains several TWiki core team user accounts and a guest user account. You probably want to remove those accounts by deleting the entries in =.htpasswd=. Do not remove the guest user if you want to allow guest logins.
		1. *Copy* the TWikiRegistrationPub topic to TWikiRegistration, overwriting old version of <nop>TWikiRegistration. Do that by either editing the topics in the%TWIKIWEB% web, or by renaming the =.txt= and =.txt,v= files in the =twiki/data/%TWIKIWEB%= directory.
	* Customization:
		* You can customize the registration form by deleting or adding input tags. The =name=""= parameter of the input tags must start with: ="Twk0..."= (if this is an optional entry), or ="Twk1..."= (if this is a required entry). This ensures that the fields are carried over into the user home page correctly.
		* You can customize the default user home page in NewUserTemplate.
	* Register yourself in the TWikiRegistration topic.
		* %X% *NOTE:* When a user registers, a new line with the username and encrypted password is added to the =data/.htpasswd= file. The =.htpasswd= file that comes with the TWiki installation includes user accounts for TWiki core team members that are used for testing on TWiki.org. You can edit the file and delete those lines.
	* Create a new topic to check if authentication works.
	* Edit the %MAINWEB%.TWikiAdminGroup topic in the TWiki:%MAINWEB% web to include users with system administrator status.
	* Edit the TWikiPreferences topic in the TWiki:%TWIKIWEB% web to set access privileges.
	* Edit the WebPreferences topic in each web, if necessary: set access priviliges.

That's it for a basic new web set-up!

Optionally, you can also:
	* Create custom web-specific templates in a new =twiki/templates/Someweb= directory (otherwise, templates are inherited from =twiki/templates=).
	* Add TWikiForms for form-based page input that's stored separately from the main free-form topic text.

%X% *NOTE:* User home topics are located in the %WIKITOOLNAME%.%MAINWEB% web - don't try to move them or create them in other webs. From any other web, user signatures have to point to %WIKITOOLNAME%.%MAINWEB% web, using a =%MAINWEB%.<nop>UserName= or =%<nop>MAINWEB%.<nop>UserName= format. (The =%<nop>MAINWEB%= variable is an advantage if you ever change the %MAINWEB% web name, but the standard =%MAINWEB%.<nop>UserName= is easier for users to enter, which is the bottom line! 

---++ TWiki File System Info

See [[AppendixFileSystem][Appendix A: TWiki File System]] for an installed system snapshot and descriptions of all files in the TWiki 01-Sep-2001 distribution.

-- PeterThoeny - 28 Dec 2002 <br />
-- Main.MikeMannix - 16 May 2002	
%STOPINCLUDE%
%META:TOPICMOVED{by="MikeMannix" date="999319650" from="TWiki.TWikiInstallationNotes" to="TWiki.TWikiInstallationGuide"}%
