13 Feb 2007 - 18:42:33 - DannyDeCockYou are here: Godot's Twiki >  Installing Web > InstallingTwiki

# Installing Twiki

# You should first install a few debian packages smile

sudo apt-get install libcgi-perl libcgi-session-perl libapache-mod-perl libunicode-maputf8-perl

# The following variables allow us to customize the location of your Twiki...

# The Twiki will arrive in a directory which is protected using userid/password. This is very convenient in environments where all users already have been registered with a userid/password. This is why no additional registration is required in the Twiki...

DOWNLOADSDIR=$HOME/downloads
APACHEUSER=www-data
THISTWIKINAME=godot
PATHTOTWIKI=/~$USER/twiki
MAINTWIKIURL=https://localhost$PATHTOTWIKI
MAINTWIKIDIR=/home/$USER
MAINTWIKIPAGES=$MAINTWIKIDIR/public_html/twiki
TWIKIMAIN=$MAINTWIKIPAGES
mkdir -p $TWIKIMAIN $MAINTWIKIPAGES

# Initialize the password of at least one user smile

MAINTWIKIPWD=$MAINTWIKIDIR/passwd
mkdir -p $MAINTWIKIPWD
echo twiki: $USER >> $MAINTWIKIPWD/twiki.group
touch $MAINTWIKIPWD/twiki.passwd
if [ `grep $USER $MAINTWIKIPWD/twiki.passwd |wc -l` == 0 ] ;then
echo enter a new password to access your twiki...
htpasswd $MAINTWIKIPWD/twiki.passwd $USER
fi

# Configuring user authentication...

echo AuthUserFile  $MAINTWIKIPWD/twiki.passwd                > $TWIKIMAIN/.htaccess
echo AuthGroupFile $MAINTWIKIPWD/twiki.group               >> $TWIKIMAIN/.htaccess
echo AuthName \"Enter your userid and password to get access to this Twiki...\"   >> $TWIKIMAIN/.htaccess
echo AuthType Basic                        >> $TWIKIMAIN/.htaccess
echo require group twiki                     >> $TWIKIMAIN/.htaccess
echo SSLRequireSSL                        >> $TWIKIMAIN/.htaccess
chmod a+r $TWIKIMAIN/.htaccess

# Download the Twiki file if you have not yet done so...

mkdir -p $DOWNLOADSDIR
cd $DOWNLOADSDIR
wget -c http://twiki.sourceforge.net/swd/TWiki20040902.tar.gz

# Unpack the source and configure it so that the testenv.cgi script gets happy...

cd $TWIKIMAIN
tar -xpzf $DOWNLOADSDIR/TWiki20040902.tar.gz 
mv twiki $THISTWIKINAME
cd $TWIKIMAIN/$THISTWIKINAME
perl -pi -e 's/..\/lib/MAINTWIKIPAGES\/THISTWIKINAME\/lib/' bin/setlib.cfg
perl -pi~ -e 's/^\$defaultUrlHost/\$defaultUrlHost="MAINTWIKIURL"\;\#/' lib/TWiki.cfg
perl -pi~ -e 's/^\$scriptUrlPath/\$scriptUrlPath="PATHTOTWIKI\/THISTWIKINAME\/bin"\;\#/' lib/TWiki.cfg
perl -pi~ -e 's/^\$pubUrlPath/\$pubUrlPath="PATHTOTWIKI\/THISTWIKINAME\/pub"\;\#/' lib/TWiki.cfg      
perl -pi~ -e 's/^\$pubDir/\$pubDir="MAINTWIKIPAGES\/THISTWIKINAME\/pub"\;\#/' lib/TWiki.cfg           
perl -pi~ -e 's/^\$templateDir/\$templateDir="MAINTWIKIPAGES\/THISTWIKINAME\/templates"\;\#/' lib/TWiki.cfg
perl -pi~ -e 's/^\$dataDir/\$dataDir="MAINTWIKIPAGES\/THISTWIKINAME\/data"\;\#/' lib/TWiki.cfg   
perl -pi~ -e 's/^\$scriptSuffix/\$scriptSuffix=".cgi"\;\#/' lib/TWiki.cfg    
perl -pi~ -e 's/THISTWIKINAME/'$THISTWIKINAME'/g' bin/setlib.cfg
perl -pi~ -e 's/THISTWIKINAME/'$THISTWIKINAME'/g' lib/TWiki.cfg
perl -pi~ -e 's/MAINTWIKIPAGES/'$(echo $MAINTWIKIPAGES|sed s/'\/'/'\\\/'/g)'/g' bin/setlib.cfg
perl -pi~ -e     's/MAINTWIKIURL/'$(echo $MAINTWIKIURL|sed s/'\/'/'\\\/'/g)'/g' lib/TWiki.cfg 
perl -pi~ -e 's/MAINTWIKIPAGES/'$(echo $MAINTWIKIPAGES|sed s/'\/'/'\\\/'/g)'/g' lib/TWiki.cfg 
perl -pi~ -e 's/PATHTOTWIKI/'$(echo $PATHTOTWIKI|sed s/'\/'/'\\\/'/g)'/g' lib/TWiki.cfg

# Make sure the templates, data and lib directories cannot be accessed from the browser environment and the web server...

cp subdir-htaccess.txt templates/.htaccess
cp subdir-htaccess.txt data/.htaccess
cp subdir-htaccess.txt lib/.htaccess 
chmod a+r */.htaccess

# The extension of the various scripts should be .cgi for most web servers... (or at least mine)

cd bin
for a in `ls|grep -v setlib.cfg`;do mv $a $a.cgi;done
cd ..

# Correct the issuer/owner of the modifications of the various files for the revision control system:

cd $TWIKIMAIN/$THISTWIKINAME/data
find . -name \*,v -exec perl -pi~ -e '$. <= 10 && s/nobody:/'$APACHEUSER':/ ' {} \;

# Make sure the webserver can write files in the data and pub directories...

cd $TWIKIMAIN/$THISTWIKINAME/
chmod o+w $TWIKIMAIN/$THISTWIKINAME/data
chmod o+w $TWIKIMAIN/$THISTWIKINAME/pub 

# Once you pasted all the lines above, you can visit the test script:

firefox https://localhost/~$USER/twiki/$THISTWIKINAME/bin/testenv.cgi

# If it produces zero or one warning(s) (i.e., if you do not run CGI scripts as nobody), you can proceed testing the actual twiki:

firefox https://localhost/~$USER/twiki/$THISTWIKINAME/bin/view.cgi

# It does not harm to make the testenv script inaccessible once you arrived at this step and you like your twiki smile

mv $TWIKIMAIN/$THISTWIKINAME/bin/testenv.cgi $TWIKIMAIN/$THISTWIKINAME/bin/testenv.cgi.

# A few (recommended) customizations...

# Make sure there are redirects in the (sub)directories of the twiki...

echo "" > $MAINTWIKIPAGES/index.html
cd $MAINTWIKIPAGES/$THISTWIKINAME
for a in `find . -type d|grep -v ./lib|grep -v ./templates|grep -v ./data`;do
   echo "" > $a/index.html
   done

# Change the pattern template to include a website search button at the page top and bottom of each twiki page:

cd $TWIKIMAIN/$THISTWIKINAME
echo >> data/TWiki/TWikiVariables.txt
echo ---++ Custom Variables >> data/TWiki/TWikiVariables.txt
echo $'\t\t'* Set PATHTOTWIKI = $PATHTOTWIKI/$THISTWIKINAME >> data/TWiki/TWikiVariables.txt
echo >> data/TWiki/TWikiVariables.txt

cd $TWIKIMAIN/$THISTWIKINAME/templates
mv view.pattern.tmpl view.pattern.tmpl.original
wget http://homes.esat.kuleuven.be/~decockd/repository/twiki/templates/view.pattern.tmpl

# Change the top bar of the twiki (and get rid of the irritating and misleading jump box)

cd $TWIKIMAIN/$THISTWIKINAME/data/TWiki
mv WebTopBar.txt WebTopBar.txt.original
wget http://homes.esat.kuleuven.be/~decockd/repository/twiki/twiki/WebTopBar.txt

# Change the _default web to placeholders

cd $TWIKIMAIN/$THISTWIKINAME/data/_default
for placeHolder in WebHome WebLeftBar;do
  mv $placeHolder.txt $placeHolder.txt.original
  wget http://homes.esat.kuleuven.be/~decockd/repository/twiki/default/$placeHolder.txt
  done

# Clean up the default Twiki content smile

rm -rf $TWIKIMAIN/$THISTWIKINAME/data/Sandbox
cd $TWIKIMAIN/$THISTWIKINAME/data
rm -rf Main
cp -a _default Main

# Disable the password management...

# This is useful as the wiki is available to users only if they have access to $MAINTWIKIURL (in this example https://localhost/$USER/twiki)
cd $MAINTWIKIPAGES/$THISTWIKINAME/bin
mv installpasswd.cgi installpasswd.cgi.
mv passwd.cgi passwd.cgi.

# Disable the registration features...

# This is also useful as the wiki is available to users only if they have access to $MAINTWIKIURL (in this example https://localhost/$USER/twiki)
cd $MAINTWIKIPAGES/$THISTWIKINAME/bin
mv register.cgi register.cgi.
cd $MAINTWIKIPAGES/$THISTWIKINAME/data/TWiki
mv TWikiRegistration.txt TWikiRegistration.txt.
mv TWikiRegistrationPub.txt TWikiRegistrationPub.txt.
for placeHolder in WebTopBar WebLeftBar;do
  mv $placeHolder.txt $placeHolder.txt.original
  wget http://homes.esat.kuleuven.be/~decockd/repository/twiki/twiki/$placeHolder.txt
  done

# Correct a bug in the comments plugin

cd $MAINTWIKIPAGES/$THISTWIKINAME/lib/TWiki/Plugins/CommentPlugin
mv Comment.pm Comment.pm.original
wget http://homes.esat.kuleuven.be/~decockd/repository/twiki/plugins/Comment.pm

# Setting file/directory read/write permissions

cd $MAINTWIKIPAGES/$THISTWIKINAME/data
find . -depth -name \*,v -exec chmod o+rw {} \;
find . -depth -name \*txt -exec chmod o+rw {} \;
find . -depth -type d -exec chmod o+rxw {} \;

# Configuring your apache web browser to make it twiki-ready:

sudo perl -pi~ -e 's/Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec/Options MultiViews ExecCGI Indexes SymLinksIfOwnerMatch IncludesNoExec/' /etc/apache-ssl/httpd.conf
sudo perl -pi~ -e 's/#AddHandler cgi-script .cgi .sh .pl/AddHandler cgi-script .cgi/' /etc/apache-ssl/httpd.conf
sudo /etc/init.d/apache-ssl restart

 

Welcome at Godot.Be

This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Godot's Twiki? Send feedback