Softice media wiki

From SOFTICE

Jump to: navigation, search

Contents

This page contains a bunch of procedures we regularly use with this wiki. The name is somewhat misleading and will be fixed in a nearby future... yes... that's it.



Installing media wiki

Refer to the installation instructions for sarge (http://meta.wikimedia.org/wiki/How_to_install_Metawiki_on_Debian_Sarge) the instructions below are deprecated

  1. Download it
    • tar-ball is an option but debian has something better:
    wget http://easynews.dl.sourceforge.net/sourceforge/wikipedia/mediawiki-1.6.7.tar.gz
    
  2. Install all necessary support software packages

    apt-get install apache php4 libapache-mod-php4 php4-gd php4-imagick php4-mysql mysql-server 
    
  3. Configure Apache

    • mediawiki uses the ServerName variable defined in your httpd.conf file.
    • Make sure it is set to your website's name. If this isn't done you'll get an error that complains about not being able to connect to localhost or some other website.
    • In apache2 add ServerName to apache2.conf (/etc/apache2/apache2.conf in Debian) file, not httpd.conf.


  4. Configure MySQL

    • Most of all you need to apply mysql root password. Remember not to use same password for system root and mysql root
    	mysqladmin -u root password xxxx
    
    • Now check if the password works:
    	mysql -u root
    

    If you see:

    ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
    

    Then mysql root account is now on password protected.


  5. Configure PHP

    • Make sure your php configuration file (/etc/php4/apache/php.ini or /etc/php4/apache2/php.ini) has this line:
    	memory_limit = 20M
    

    and the following lines uncommented:

    	extension=mysql.so
    	extension=gd.so
    
    • restart apache / apache2
    	apachectl restart
    	apache2ctl restart
    
  6. Configure PHP

    • Make sure your php configuration file (/etc/php4/apache/php.ini or /etc/php4/apache2/php.ini) has this line:
    memory_limit = 20M
    

    and the following lines uncommented:

    extension=mysql.so
    extension=gd.so
    
    • restart apache / apache2
    apachectl restart
    apache2ctl restart
    


  7. untar tarball in appropriate dir and point web browser to it
  8. Finalizing Installationg
    chmod a+w config 
    mv ./config/xxx ./
    rm -r config 
    


    Remarks

    • for apache2 php may not be executed, look up in /etc/apache2/apache2.conf and uncomment the following (.phtml wasn't there):
    AddType application/x=httpd-php .php .phtml
    
    • make sure that the following is also there:
    DirectoryIndex index.html index.cgi index.pl index.php index.xhtml
    

Mirroring the wiki

On the source hosts

/usr/local/bin/bck-wiki.sh

#!/bin/bash
ID=/usr/bin/id
BCK_DB_FILE=wiki.`date +%F`.database.sql
BCK_IMG_FILE=wiki.`date +%F`.uploads.tgz

BCK_DIR=/home/www/downloads/backups
CMD_SQLDUMP=/usr/bin/mysqldump
WIKI_UPLOADS_DIR=/home/www/wiki/images/


PASSWORD="hackme"


# make sure we're running as root
if (( `$ID -u` != 0 ));
then { $ECHO "Sorry, must be root.  Exiting..."; exit; } fi

cd $BCK_DIR
$CMD_SQLDUMP  -u root --password=$PASSWORD --single-transaction wikidb > $BCK_DB_FILE

chown -R www-data:www-data $BCK_DB_FILE
chmod a+r $BCK_DB_FILE

#taking care of the uploaded documents
cd $WIKI_UPLOADS_DIR
tar czf ./$BCK_IMG_FILE  ./$WIKI_UPLOADS_DIRNAME

mv $BCK_IMG_FILE $BCK_DIR/
cd $BCK_DIR

chown -R www-data:www-data $BCK_IMG_FILE
chmod a+r $BCK_IMG_FILE


cd -


exit 0

On the destination host

/usr/local/bin/bck-wiki-get.sh

#!/bin/bash
ID=/usr/bin/id
BCK_DB_FILE=wiki.`date +%F`.database.sql
BCK_IMG_FILE=wiki.`date +%F`.uploads.tgz                                        

CMD_MYSQL=/usr/bin/mysql
BCK_DIR=/home/wiki-backups/

WIKI_UPLOADS_DIR=/var/www/wiki/
WIKI_UPLOADS_DIRNAME=images/

PASSWORD="hackmeplenty"

# make sure we're running as root
if (( `$ID -u` != 0 ));
then { $ECHO "Sorry, must be root.  Exiting..."; exit; } fi

#fetch the latest backup file from masternode
cd $BCK_DIR
wget http://softice.lakeland.usf.edu/downloads/backups/$BCK_DB_FILE
wget http://softice.lakeland.usf.edu/downloads/backups/$BCK_IMG_FILE

#wipe the surrent wiki db data base
echo "drop database wikidb" | $CMD_MYSQL --user=root --password=$PASSWORD wikid\
b
#create empty wikidb
echo "create database wikidb" | $CMD_MYSQL --user=root --password=$PASSWORD
#restore data base
$CMD_MYSQL --user=root --password=$PASSWORD wikidb < ./$BCK_DB_FILE

#taking care of uploaded documents
cp $BCK_IMG_FILE $WIKI_UPLOADS_DIR


cd $WIKI_UPLOADS_DIR
rm -rf $WIKI_UPLOADS_DIRNAME
tar oxzf $BCK_IMG_FILE
rm $BCK_IMG_FILE
chown -R www-data:www-data $WIKI_UPLOADS_DIRNAME

cd $BCK_DIR
gzip -9 $BCK_DB_FILE

cd -
exit 0

Backing up generic procedures

Backuping the wiki

Reference is the meta wiki site "how to move a wiki" http://meta.wikimedia.org/wiki/Backup_Database

From their page:

1. Dump the SQL database from oldsite.
2. Keep copy of LocalSettings.php.
3. Create new (empty and default) instance of Mediawiki.
Or delay this step after step 4 and fill the database name and other settings same to those  when you were installing your old one.
4. create database on the new machine, Load SQL dump into new database.
5. Move images directory from oldsite to newsite.
Customize LocalSettings.php and database to match each other and new server.
"You might have to manually set up MySQL user access permissions again, depending on the setup"

These are the generic steps, let's look at how to dump the database:

mysqldump -u root -p --single-transaction wikidb > backup.sql
Enter password: *******

if in doubt about password or data base name check out /home/www/sys/wiki/LocalSettings.php


Just a tiny script doing a backup of the wiki contents

#!/bin/bash


# make sure we're running as root
if (( `$ID -u` != 0 )); then { $ECHO "Sorry, must be root.  Exiting..."; exit; } fi

#check usage 
if [[ $# != 1 ]]
then 
   echo "Specify date in format yyyyxmmxdd"
   exit 1; 
fi 

cd /root/wiki-backups/

/usr/bin/mysqldump -u root -p --single-transaction wikidb > backup.sql

mv backup.sql "$1.wiki.sql"
cp "$1.wiki.sql" /home/alessio/wiki_backups/
exit 0 


Restoring the wiki

To restore the wiki from this backup file (have a look at http://www.aota.net/PHP_and_MySQL/mysqlbackup.php4):

mysql -u root -p wikidb < /home/wiki-backups/wiki.2006-xx-xx.sql

here's a little script that we run on another machine to get the daily wiki backup from the master node and replicate it.


#!/bin/bash 

ID=/usr/bin/id
BCK_FILE=wiki.`date +%F`.sql
BCK_DIR=/home/wiki-backups

CMD_MYSQL=/usr/bin/mysql
PASSWORD="hackmeplenty"


# make sure we're running as root
if (( `$ID -u` != 0 )); 
then { $ECHO "Sorry, must be root.  Exiting..."; exit; } fi

#fetch the latest backup file from masternode
cd $BCK_DIR
wget http://softice.lakeland.usf.edu/downloads/backups/$BCK_FILE


#wipe the surrent wiki db data base 
echo "drop database wikidb" | $CMD_MYSQL --user=root --password=$PASSWORD wikidb 

#create empty wikidb 
echo "create database wikidb" | $CMD_MYSQL --user=root --password=$PASSWORD 


#restore data base 
$CMD_MYSQL --user=root --password=$PASSWORD wikidb < ./$BCK_FILE

cd - 
exit 0



Miscellaneous Stuff

Locking the Wiki (updated)

The purpose of the Wiki lockdown is to prevent anonymous users from creating users for the Wiki who have the ability to login and edit or make unwanted changes to the Wiki.

Recommended modifications to the LocalSettings.php file were not effective. Eventual modifications to the DefaultSettings.php file effectively locked down the Wiki, preventing the creation of unwanted users on the Wiki.

On the softice.lakeland.usf.edu server, the DefaultSettings.php file is located in the /home/www/wiki/includes directory. The $wgWhilelistEdit variable needs to be reset to "true." Setting this variable to "true" prevents anonymous users from editing the Wiki. For the $wgWhitelistAccount variable, the element value for the element key 'user' needs to be reset to "0." Setting this variable element key to the value of "0" will prevent the creation of Wiki users by an anonymous user. Note the following changes:


Edit file:    /home/www/wiki/includes/DefaultSettings.php

Locate line:  $wgWhitelistEdit = false;
Edit line to: $wgWhitelistEdit = true;

Locate line:  $wgWhitelistAccount = array ( 'user' => 1, 'sysop' => 1, 'developer' => 1 );
Edit line to: $wgWhitelistAccount = array ( 'user' => 0, 'sysop' => 1, 'developer' => 1 );

References:
http://meta.wikimedia.org/wiki/Setting_user_rights_in_MediaWiki
http://meta.wikimedia.org/wiki/Help:User_rights

Locking the wiki

From:

http://meta.wikimedia.org/wiki/MediaWiki_FAQ#How_do_I_allow_only_logged-in_users_to_edit.3F

First:

$wgWhitelistEdit = true;

UPDATED by -Sx- for 1.5Beta1: To stop people from creating accounts and/or anonymously editing pages, in the LocalSettings.php, add either of these 2 lines:

// Only SysOp (Admin) can create accounts -
$wgGroupPermissions['*']['createaccount'] = false;

or

// No anonymous editing allowed -
$wgGroupPermissions['*']['edit'] = false;


Replacing the wiki logo image

http://www.mediawiki.org/wiki/Help:FAQ#How_do_I_change_the_logo.3F

References

Mediawiki main page

Installing Mediawiki on debian

Personal tools