Website Setup

From BPWiki
Jump to: navigation, search

Overall Setup

Multiple CMS's are run on the same server with each occupying their own directory. Redirects via .htaccess to point to the right instance. Underneath all of this is a basic html site in case of database failure.

Make sure you exclude any directories that shouldn't appear in search engines in robots.txt

Current Structure

  • /w - Mediawiki
  • /wiki - Public facing virtual directory for Mediawiki pages
  • /wordpress - Wordpress

Wordpress Setup

  • Use en-au localisation, mate.
  • Send admin emails to a group email to all administrators

Mediawiki Setup

Mediawiki is used with the following local modifications at the file level

  • Version 1.5.0 was previously installed and the current version installed over the top. In Version 1.5.0 newline removed from end of includes/SpecialUpload.php removed 9 Sep 2010
  • A Google sitemap was generated at some stage using code from http://www.thinklemon.com/wiki/MediaWiki:Google_Sitemaps but this is no longer used
  • An old version 1.14.0 is used (should be upgraded) upgraded 7 Oct 2010

The installation is normal with

  • Apache used as the web server
  • MySQL used for database server
  • InnoDB is used for database storage (from 15 September 2010)
  • The database character set is MySQL 4.0 backwards-compatable UTF-8. This should be changed to MySQL 4.1/5.0 binary
  • Whilst shell access can be made available, avoid using it if at all possible, the CPanel interface is preferred
  • images in the images directory
  • an AdminSettings.php file with $wgDBadminuser and $wgDBadminuser set to the local database created from AdminSettings.sample
  • a LocalSettings.php file with many local modifications
  • In the Mediawiki namespace
  • Install ParserFunctions if MediaWiki 1.18 or later is not installed, the inbuilt string functions are not enabled.

Installing Mediawiki under CPanel

If the mod_security2 module is enabled in Apache, editing pages containing more than a few links will fail and generate a 404 error on index.php. To resolve this raise a fault docket with the hosting provider to remove mod_security for the hosting account as suggested by Mediawiki documentation or possibly just have the particular rule disabled for this account. Note that mod_security2 rules or in fact any feature of it cannot be modified in .htaccess with a default CPanel installation.

Change from MyISAM to InnoDB

  1. Enable read-only mode in LocalSettings.php:
    $wgReadOnly = 'Upgrading to InnoDB';
  2. Take a backup of database
  3. Using PHPMyAdmin change each table type to InnoDB except for:
    • Leave table hitcounter as type Memory
    • Leave table searchindex as type MyISAM
  4. Alter LocalSettings.php:
# If you're on MySQL 3.x, this next line must be FALSE:<br />
$wgDBmysql4 = true;

change to

# MySQL table options to use during installation or update
$wgDBTableOptions   = "TYPE=InnoDB";

# Experimental charset support for MySQL 4.1/5.0.
$wgDBmysql5 = false;
  1. Disable read-only mode in LocalSettings.php by removing $wgReadOnly line.

Upgrade Mediawiki version

  1. Enable read-only mode in LocalSettings.php at the end of the file:
    $wgReadOnly = 'Upgrading to new version';
  2. Take a backup of database to local storage
  3. Take a backup of contents of the /w directory tree to local storage (can compress to a zip file from cPanel file manager, then download)
  4. Copy the new distribution version of Mediawiki to the public_html directory
  5. Extract the new Mediawiki version, which will create a new directory /Mediawiki-new.version/images
  6. Copy the contents of the /w/images directory to /Mediawiki-new.version/images
  7. Create a new database user
  8. Create a new database
  9. Copy the existing database, the new version will use this and the new user
  10. Grant the new user rights to the new database
  11. Install the new version within the /Mediawiki-new.version directory
  12. Add local modifications (see below)
  13. Enable read-only mode in LocalSettings.php at the end of the file:
    $wgReadOnly = 'Upgrading to new version';
  14. Complete testing of new version
  15. To finish installation (reverse for rollback)
    1. Rename old /w directory to /Mediawiki-old.version and rename /Mediawiki-new.version directory to /w
    2. Complete testing of new version in place
  16. Disable read-only mode in LocalSettings.php by removing $wgReadOnly line.
  17. Complete testing of new version with writeable database, if rollback from here, changes will be lost.
  18. At some point delete old database and files

Who can edit

Prevent anonymous users from editing and allow only SysOps to create accounts by setting in LocalSettings.php

$wgGroupPermissions['*'    ]['edit']            = false;
$wgGroupPermissions['*'    ]['createaccount']            = false;

Allow sysops to delete revisions of pages if required

$wgGroupPermissions['sysop']['deleterevision']  = true;

Image Uploading

  • Safe mode was used in the past so in LocalSettings.php set:
$wgHashedUploadDirectory = false;
  • Set the wiki images,images/archives,images/thumbs and images/temp directories to be world write (757)
  • Enable image uploading so in LocalSettings.php set:
$wgEnableUploads       = true;
  • Add PDF, SVG and EPS file type to the list of allowable uploads, so in LocalSettings.php set:
$wgFileExtensions = array_merge(
    $wgFileExtensions, array(
        'pdf', 'sag', 'eps'
        )
    );
  • passthru() appears to be disabled in PHP so disable the use of ImageMagick in LocalSettings.php by
# $wgUseImageMagick = true;
# $wgImageMagickConvertCommand = "/usr/bin/convert";

Links to telephone numbers

Allow links using the tel: schema by adding an entry to LocalSettings.php as follows

# Allow tel: links
$wgUrlProtocols[] = "tel:";

Short URL's

Short urls are used, ie. http://www.bpuc.org/wiki/Articlename. This is implemented using the procedure outlined for servers without web access:

  1. Choose the virtual directory /wiki/ in which you want your articles to appear (as Wikipedia does).
  2. Install MediaWiki in /w/ relative to your web root (as Wikipedia does).
  3. Add or edit the following setting in LocalSettings.php. This will cause the HTML generated by MediaWiki to refer to "/wiki/Articlename" instead of the default:
    $wgScriptPath = "/w";         # Physical path (right part of first rewrite rule). Should 
                                  # already be in LocalSettings.php
    $wgArticlePath = "/wiki/$1";  # Virtual path (left part of first rewrite rule). MUST be 
                                  # DIFFERENT from the path set above ($wgScriptPath)!
    $wgUsePathInfo = true; 
    
  4. Create or edit .htaccess in your web root directory (typically, public_html) adding:
    RewriteEngine On
    RewriteRule ^wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA]
    RewriteRule ^wiki/*$ /w/index.php [L,QSA]
    RewriteRule ^/*$ /w/index.php [L,QSA]
    

    RewriteRule defines virtual paths and how they should be rewritten; in the example above, /wiki/Page will cause /w/index.php?title=Page to be loaded instead.

  5. Set robots.txt to stop robots crawling all over where they are unwanted

Preserving old URLs

To keep URLs from the older static HTML website working add the following lines to .htaccess in your web root directory (typically, public_html) adding:

RewriteRule ^people/ken_anderson\.html$ /wiki/Ken_Anderson [R]
RewriteRule ^index\.html$ /wiki/Main_Page [R]
RewriteRule ^wedding /wiki/Wedding [R]
RewriteRule ^prayer\.html$ /wiki/Prayer [R]
RewriteRule ^jokes\.html$ /wiki/Jokes [R]
RewriteRule ^baptism\.html$ /wiki/Baptism [R]

CPanel additions to .htaccess

CPanel adds two sections for 403 errors and to deny access from an annoying robot:

<Files 403.shtml>
order allow,deny
allow from all
</Files>

deny from 1.2.3.4 (annoying robot we want to block)

Look and Feel

Use the church logo

  • by modifying LocalSettings.php to set:
$wgLogo = "/images/bpuclogos.png"; # Point to logo
  • Church logo uploaded to /images/bpuclogos.png

The standard monobook skin is modified:

  • Remove the edit buttons etc for all except logged in users by modifying skins/Monobook.php
*** 132,137 ****
--- 132,138 ----
        </div>
                </div>
                <div id="column-one">
+         <?php if($this->data['loggedin']) { ?>
        <div id="p-cactions" class="portlet">
                <h5><?php $this->msg('views') ?></h5>
                <div class="pBody">
***************
*** 160,165 ****
--- 161,167 ----
                        </ul>
                </div>
        </div>
+         <?php } ?>
        <div class="portlet" id="p-personal">
               <h5><?php $this->msg('personaltools') ?></h5>
                <div class="pBody">
  • Set in the BPWiki namespace:
    • About to "This is the website of Brougham Place Uniting Church. It is a Wiki so that all members of the Brougham Place Community can contribute to it."
    • Current events set to avoid double redirect
#REDIRECT [[Current events]]
  • Set in the MediaWiki namespace:
    • Contact set to "Contact us"
    • Contact-url set to "Contact"
    • Monobook.css customised
/* CSS placed here will affect users of the Monobook skin */

body.page-Main_Page h1.firstHeading { display:none; }

body { background: #F0FFFF; }
* navigation
** mainpage|mainpage
** currentevents-url|currentevents
** recentchanges-url|recentchanges
** randompage-url|randompage
** helppage|help
** contact-url|contact

Listing Directories

The Apache directory listing is disabled by the host. Use Directory lister instead. Be careful not to delete the index.php file when cleaning up directories that are listed.