Manual:Running MediaWiki on FreeBSD

This installation guide assumes you are installing on the local machine (localhost) and that you are logged in as the superuser (root). Also, this guide based on FreeBSD 8.0, PHP 5.2, MySQL 5.0, MediaWiki 1.13, and Apache 2.2. Other software versions might require slightly different steps. Instructions for older versions of FreeBSD are below.

Install Apache, PHP, MySQL, and MediaWiki
These can either be installed from binaries (using pkg_add) or from source via the ports tree under /usr/ports.

To install from binaries (faster option):

pkg_add -r apache22 pkg_add -r mysql-server pkg_add -r php5 pkg_add -r php5-mysql pkg_add -r mediawiki

Unfortunately, the binary installation of php5 does not include mod_php, which is needed by Apache to execute PHP code in pages. Therefore:

cd /usr/ports/lang/php5 make config make make deinstall make reinstall

During the make config step, enable the "APACHE" option in the menu.

Set up MySQL
The easiest method is to only set a root password and then let the MediaWiki installer script do the rest:

mysqladmin -u root password password history -c

Use

mysql-server onestart

to start MySQL.

Edit /usr/local/etc/apache22/httpd.conf
Make sure the following sections have been added to /usr/local/etc/apache22/httpd.conf:

LoadModule php5_module       libexec/apache/libphp5.so

AddModule mod_php5.c           DirectoryIndex index.php index.html         AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 

If you want to serve MediaWiki content exclusively, you can simply change the Apache document root to the MediaWiki installation directory:

DocumentRoot "/usr/local/www/mediawiki"

Also add an entry for the MediaWiki directory to httpd.conf</tt>:

<Directory "/usr/local/www/mediawiki"> Options Indexes FollowSymLinks DirectoryIndex index.php index.html AllowOverride None Order allow,deny Allow from all </Directory>

Use

apachectl restart

to launch (or relaunch) Apache. Open http://localhost in your browser to see if Apache works.

Edit /etc/rc.conf
Make sure your hostname</tt> in rc.conf</tt> contains a domain name, and that Apache and MySQL are set to start automatically during boot:

hostname="mycomputer.example.com" apache22_enable="YES" mysql_enable="YES"

Run the MediaWiki web installer
cd /usr/local/www/mediawiki chmod 777 config mkdir images chown www images

Now open http://localhost/mediawiki/config/index.php in your browser to start installation. Enter root</tt> and your MySQL root password in the appropriate boxes. See Manual:Config script for more information.

When the installer has finished successfully, copy the resulting settings file:

cd /usr/local/www/mediawiki cp config/LocalSettings.php. chmod 700 config

Edit /usr/local/www/mediawiki/LocalSettings.php
You will probably want to enable uploads and change the logo. The logo image should be 135 pixels square.

$wgEnableUploads = true; $wgLogo = "http://mycomputer.example.com/my_logo.png";

Further configuration of FreeBSD
Please note that your Apache server will also serve pages to everyone else on the local network. You may want to check your firewall settings if you do not want to make your MediaWiki content available to other machines.

Database
Install MySQL from ports, databases/mysql40-server.

Web server
''' Apache can be installed from ports, www/apache13 or www/apache2.

TeX support
Install these from ports for math rendering support if you haven't already got them:


 * lang/ocaml
 * print/latex
 * print/dvips
 * graphics/ImageMagick
 * print/ghostscript-gnu-nox11

For FreeBSD 4.11 users: please install the following packages instead because dvips is not available in the package list: teTeX already includes latex and dvips. However, it will conflict with latex2e. So please make sure that your system does not have latex2e.
 * ocaml
 * teTeX
 * ImageMagick
 * gmake

texvc's Makefile requires GNU make. Once ocaml is installed, go into the math/ subdirectory of the MediaWiki package and run 'gmake'. The texvc executable will be installed by install.php if you use it and have $wgUseTeX set to true, or you can copy it in manually. Put it in 'math' subdirectory under where wiki.phtml is.

Note that certain versions of FreeBSD (5.3) may require a cvsup of the ports directory to work correctly. If you attempt this installation and run into errors, try cvsup'ing your ports tree and remaking the above ports -- ImageMagick specifically.

The MediaWiki-1.1.0 and earlier releases use an option for dvips which the ports version doesn't support. The latest CVS version has used a more compatible option; if using an older release, edit render.ml and change "-o -" to "-f" at the end of the first line, then build texvc.

Note that latex, dvips, and convert must be in the PATH for texvc to shell out to them. If apache is started on system startup it may not have /usr/local/bin in the PATH, and this PATH will be inherited by texvc and image output won't happen. Restart apache after boot, or put this into LocalSettings.php:

putenv("PATH=".getenv("PATH").":/usr/local/bin");

In some installations, dvips seems to have problems with texvc's command line parameters: it doesn't recognize 'ps:-</tt>' as an input filename specifier for stdin. Change this line to use plain '-</tt>' in file render.ml</tt> and compile texvc again:

let cmd_convert finalpath = "/usr/local/bin/convert -quality 100 -density 120 - " ^ finalpath ^ " >/dev/null 2>/dev/null"

Matrix Support
The default install of math libraries will not have the asmfonts installed. Asmfonts are used for matrix, bmatrix, and pmatrix math libraries.

Instructions and fonts can be obtained from the following links:


 * http://www.ams.org/tex/distrib.html#unix
 * http://www.ams.org/tex/amsfonts.html

Likely, the fonts will need to be installed in /usr/local/share/texmf

FreeBSD 6.2
I installed MediaWiki on FreeBSD 6.2 through ports.

Requirements:

Apache; PHP; MySQL; teTeX;

teTeX
On FreeBSD 6.2 I had previously installed the LaTeX port. This worked for some math typesetting, but not for matrices, vectors, and things like \mathbb{R}.

I had to remove the latex port:

Update my ports tree using :

Then install the teTex port:

Then restart the apache web server:

Now I have access to vectors, matrices, \mathbb{}, and all the amsfonts characters. amsfonts is called amspsfnt in the FreeBSD ports tree, and is installed as part of the teTeX port.

Memcached
Install it from databases/memcached. Please note, that it should not be reachable from outside, as that would cause severe security risks for your installation. If you're running on a jail, your localhost address would be mapped to a Net-visible address.

Some problems and workarounds

 * I have different configurations for standalone php and module-php. install.php database functions don't work in standalone php.


 * Workaround - run install.php from commandline to copy files. Then copy it to install2.php and comment out parts which copy files. Also hard-code db root password and delete lines where commandline input is expected. Run install2.php by accessing it from the webserver.


 * I've installed MediaWiki with Cs locales and wiki.phtml doesn't work.


 * LanguageCs needs LanguageUtf8.php to work. Copy LanguageUtf8.php to the same directory as LanguageCs.php

wiki.phtml still does not work


 * Hard-code including LanguageCs.php after Language.php in Setup.php

"PHP's XML module is missing; the wiki requires functions in this module and won't work in this configuration. If you're running Mandrake, install the php-xml package."
 * During installation i get this error message:


 * Make sure php extensions port is installed.

$cd /usr/ports/lang/php(4|5)-extensions $make install distclean


 * select xml from the menu

$ldconfig (to link newly installed xml library)


 * Restart apache.