Mediawiki Install FC6

From Aktivix
Revision as of 00:51, 21 January 2007 by Chris (Talk | contribs)

Jump to: navigation, search

See also MediaWiki_Install

The documention here is based on the FC6 mediawiki and having multiple wiki's running all on the same ip address, on different domain names, with all http port 80 requests redirected to port 443 and a CAcert cert with all the domain names.

Install

Fedora Core six has packaged mediawiki, and also seems to come with more apache packages that needed:

rpm -e mod_python mod_perl
yum install mediawiki mysql-server php-eaccelerator
chkconfig mysqld on
chkconfig httpd on
service mysqld start
service httpd start
mysqladmin -u root password 'new-password'

Then, following the wiki farm notes

elinks http://localhost/mediawiki/config/index.php

The fill in the following values (the rest can be the defaults):

Wiki name:             TestWiki1
Contact e-mail:        mediawiki @ aktivix.org
Admin username:        WikiSysop
Password:              *****
Password cobfirm:      *****
Shared memory caching: 
  * (X) eAccelerator
Database name:         testwiki1
DB username:           testwiki1user
DB password:           *****
DB password confirm:   *****
Superuser account:     root
Superuser password:    *****

Create a MySQL account for AdminSettings.php:

mysql -uroot -p mysql
mysql> GRANT ALL PRIVILEGES ON *.* TO 'wikiadmin'@'localhost'
  -> IDENTIFIED BY '****' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)

And move the sample file and then add the password to it:

cd /var/www/mediawiki
mv AdminSettings.sample AdminSettings.php

Then

cd /var/www/mediawiki
mv config/LocalSettings.php LocalSettings.php
chown root.root LocalSettings.php 
chmod 644 LocalSettings.php 

Then restart apache and the wiki should be working at http://localhost/mediawiki/

Next add a new wiki site.

Create this script, which is based on this document:

 #!/bin/bash
 
 if [[ -z $1 ]]; then
   echo "The first argument should be the new wiki name"
 fi
 
 BASE_DIR="/var/www"
 WIKI_NAME="$1"
 
 if [[ -d $BASE_DIR/$WIKI_NAME ]]; then
   echo "$WIKI_NAME appears to be in use"
   exit
 fi
 
 # make the directory for the site
 mkdir $BASE_DIR/$WIKI_NAME
 
 # change to the sites directory
 cd $BASE_DIR/$WIKI_NAME
 
 #make some dirs 
 mkdir {images,config}
 
 # fix the ownership
 chown -R apache.apache {images,config}
 
 # create the sym link tree
 for name in `ls ../mediawiki`
 do
   if [[ -e $name ]]; then
     echo "$name exists already, skipping" 
   else
     ln -s ../mediawiki/$name
   fi
 done
 
 # remove the LocalSettings.php sym link
 if [[ -L LocalSettings.php ]]; then
   rm LocalSettings.php
 else
   if [[ -f LocalSettings.php ]]; then
     echo "LocalSettings.php already exists"
   else
     echo "LocalSettings.php doesn't exist"
   fi
 fi

Redirecting port 80 to 443, create /var/www/cgi-bin/index.pl

#!/usr/bin/perl -wT 

# Redirect all http requests to https
my $server_name = "$ENV{'SERVER_NAME'}";
my $location = "";
my $path_info = "$ENV{'PATH_INFO'}";

# for some sites we need an extra redirect if www is missed off
if ($server_name eq "sheffieldagainstwar.org.uk") {
  $server_name = "https://www.sheffieldagainstwar.org.uk";
}
else {
  $server_name = "$ENV{'SERVER_NAME'}";
}

# construct the url and redirect
$location = "https://" . "$server_name" . "$path_info";
print qq~Location: $location

~;

1;

And an apache conf file, /etc/httpd/conf.d/vhosts.conf

# Editor: vim:syn=apache

NameVirtualHost *:80
<VirtualHost>
  ServerName wiki.aktivix.org
  ServerSignature Off
  UseCanonicalName Off
  AddDefaultCharset UTF-8
  ScriptAlias / "/var/www/cgi-bin/index.pl/"
  <Directory "/var/www/cgi-bin">
    AllowOverride None
    Options ExecCGI
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

NameVirtualHost *:443
Include vhosts.d/*