MediaWiki 1.12 setup procedure on Debian Etch

From MediaWiki extension testing
Jump to: navigation, search

Contents

Setting up package management

# Firstly we need to update Debian's knowledge of the available packages:
apt-get update

# Then we install aptitude, which is a fairly smart package manager, and I think is now recommended as a better version of apt-get. (say "Y" when prompted).
apt-get install aptitude

# Now we update the installed software, so that we have all latest bugfixes and security fixes. (say "Y" when prompted).
aptitude upgrade

Installing needed packages for PHP and MySQL

# Install LAMP:
aptitude install php5 php5-gd php5-cgi php5-mysql mysql-server mysql-client php5-curl lynx php-pear \
ca-certificates xml-core apache2 libapache2-mod-php5

Installing extra packages

These are not essential, but these packages could be potentially useful to us, (e.g. in compiling code, getting things from subversion, etc) :

# Install favourite simple text editor
aptitude install nano

# Install a port mapper to see which ports are open
aptitude install nmap 

# Tidying web pages.
aptitude install tidy

# useful utility
aptitude install curl

# For building PHP modules:
aptitude install php5-dev

# To be able to compile PHP from snaps.php.net
aptitude install flex libxml2-dev

# Various compression utilities:
aptitude install p7zip zip unzip bzip2 p7zip-full

# Various other packages:
aptitude install diffstat
aptitude install subversion subversion-tools patch xsltproc

Configure php.ini

Configuring PHP.ini

cp /etc/php5/apache2/php.ini /etc/php5/apache2/orig-php.ini
nano /etc/php5/apache2/php.ini

... and make these changes:

- ;date.timezone =
+ date.timezone = Europe/Amsterdam

# hide PHP in the headers
- expose_php = On
+ expose_php = Off

- memory_limit = 16M
+ memory_limit = 32M

- upload_max_filesize = 2M
+ upload_max_filesize = 10M

- allow_url_fopen = On
+ allow_url_fopen = 0

Then need to restart apache for changes to take effect:

/etc/init.d/apache2 force-reload

Then soft-link the command line php.ini to the apache php.ini, so that they can have a shared configuration:

mv /etc/php5/cli/php.ini /etc/php5/cli/php.ini-orig
ln -s /etc/php5/apache2/php.ini /etc/php5/cli/php.ini
ls -al /etc/php5/cli/php.ini

Tweak MySQL configuration

Edit configuration file:

nano /etc/mysql/my.cnf

... and add these settings to increase performance a bit:

# change from listed default of 16 to 64  :
- key_buffer              = 16M
+ key_buffer              = 64M
# uncomment, and change from default of 64 to 256:
- # table_cache             = 64
+ table_cache             = 256
# Add this on the line after the above
+ sort_buffer             = 4M

Then to make changes take effect:

/etc/init.d/mysql restart

Install APC opcode cache for PHP

This will make PHP pages like MediaWiki load slightly faster.

Installing APC as the opcode cache:

Install required dependencies:

aptitude install apache2-dev
aptitude install build-essential

Install APC (choose "yes" when prompted) :

pecl install apc

Then:

nano /etc/php5/apache2/php.ini

... and add these 3 lines to the end:

; APC opcode cache:
extension=apc.so
apc.mmap_file_mask=/tmp/apc.XXXXXX

Then reload apache:

/etc/init.d/apache2 restart

Check that there are no errors in the error log:

tail -20 /var/log/apache2/error.log

Setting up Apache virtual hosting

Load the mass virtual hosting module:

a2enmod vhost_alias

Then "nano /etc/apache2/apache2.conf", and add this to the end of the file to enable mass virtual hosting:

# ---------------------------------------------------
# ---------------- Virtual Hosting ------------------
<IfModule mod_vhost_alias.c>

# Get the server name from the Host: header
UseCanonicalName Off

# The virtual document root is under /var/www/__name_of_whatever_was_requested__
VirtualDocumentRoot /var/www/%0

# Note: Regrettably, cannot set up separate SSL certs for each virtual host here (need different IPs or ports)
# see: http://www.mail-archive.com/modssl-users@modssl.org/msg15648.html

</IfModule>
# ---------------------------------------------------

Then check above syntax is OK:

apache2ctl -t

Then restart apache:

/etc/init.d/apache2 force-reload

Then try to access a page by the hostname (e.g. "http://IP-address"). Should get an error like "The requested URL / was not found on this server." Also a "tail -f /var/log/apache2/error.log" should show an entry like: "File does not exist: /var/www/IP-address". This indicates that virtual hosting is working.

Download and unpack mediawiki

cd /var/www
wget http://download.wikimedia.org/mediawiki/1.12/mediawiki-1.12.0.tar.gz
tar xfvz mediawiki-1.12.0.tar.gz
rm mediawiki-1.12.0.tar.gz

Now make the directory and symbolic link for the MediaWiki virtual host:

ln -s mediawiki-1.12.0 83.149.110.224

If we do the following command, then we need to finish configuration below in the "Web setup of MediaWiki" step. (i.e. can stop now and come back later, but if we do this following command then do not stop at this point, otherwise anyone on the internet can complete the installation incorrectly). Make the config directory writeable, so that we can install and configure MediaWiki.

chmod a+w mediawiki-1.12.0/config

Web setup of MediaWiki

Cleaning up after setup of MediaWiki

A few last things back on the command line:

mv mediawiki-1.12.0/config/LocalSettings.php mediawiki-1.12.0/LocalSettings.php
rm mediawiki-1.12.0/config/index.php*
rmdir mediawiki-1.12.0/config

And a few other things to help us with version upgrades in the future:

cp mediawiki-1.12.0/AdminSettings.sample mediawiki-1.12.0/AdminSettings.php
chmod 640 mediawiki-1.12.0/AdminSettings.php
nano -w mediawiki-1.12.0/AdminSettings.php
# enter the "DB username" and the "DB password" from the "Web setup of MediaWiki" step above as the new $wgDBadminuser and $wgDBadminpassword values.
# Save changes, and close.

Customising and using MediaWiki

Congratulations, MediaWiki should now be installed in the basic configuration.

Various things that can or should be done at this point include:

Location

The wiki is located in the directory :

var/www/mediawiki-1.12.0
Personal tools
Namespaces
Variants
Actions
navigation
Toolbox