Archive for the ‘programming’ Category

Installing deal.II v6.2.1 (deal II) on Mac OSX v10.5.8

Monday, September 21st, 2009

Apparently installing deal.II (finite element library) on a Mac, seems like a fairly straightforward thing, in practice it took me a loot of time to do it because there was one very nasty thing that had to be done and it was not at all obvious. So I try here to give a walkthrough of all the steps I took to install deal.II on my mac. I installed it with MPI, so that I could use the multiprocessing capabilities.PRE-REQUISITESIn order to install deal.II you need to have installed some other packages:

  • LAPACK and BLAS
  • OpenMPI (v1.3.3)
  • Boost (v1.4.0)
  • PETSc (v2.3.3)

Let’s do it by parts, you should follow this order of installation:Directory structureI decided to install all libraries, except the compiler and LAPACK and BLAS on my home directory. I put all my source files and downloaded archived on a folder:~/Programs/srcAll the installed libraries I put them on a folder inside:~/Programs/installSo, most probably you do not have this directory structure hence open a terminal window and do the following to create these directories:

1
mkdir ~/Programs
2
mkdir ~/Programs/src
3
mkdir ~/Programs/install

LAPACK and BLASIn order to compile anything you need a compiler, hence you need something like the gcc collection. You can use some other compilers but I haven’t tried them. The easiest way to get up and running with compilers on a mac it’s by installing Xcode and the Xcode gFortran plugin. With this you get the gcc collection and also gfortran.For free you also get an optimized version of LAPACK and BLAS with vecLib. Hence you don’t need to have any additional work in order to have LAPACK and BLAS installed.OpenMPII installed version 1.3.3. You can dowload it from here. You can either download it from the browser and put it in the ~/Programs/src folder or you can go to the terminal and do:

1
cd ~/Programs/src
2
wget http://www.open-mpi.org/software/ompi/v1.3/downloads/openmpi-1.3.3.tar.gz

After this just extract the contents of the archive:

3
tar xvf openmpi-1.3.3.tar.gz

Now go inside the newly created directory:

4
cd openmpi-1.3.3

Run configure with the prefix to the directory where we want to install openMPI, in this case inside ~/Programs/install/openmpi:

5
./configure --prefix=~/Programs/install/openmpi

This should configure all the compilation variables with no problem so, after all the output just start compiling:

6
make all

Then install:

7
make install

If everything went fine you should have openMPI installed properly. Now it is only necessary to update your PATH and some other environment variables. To do that you need to edit your .bash_profile file, hence to do it type:

8
emacs ~/.bash_profile

Once emacs is open with your .bash_profile file, just add the following lines to it:

# Set up environment variables for openmpiexport PATH=/Users/gorkiana/Programs/install/openmpi/bin:${PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib/openmpi:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/include:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/include/openmpi/ompi/mpi/cxx/:${LD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib:${DYLD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/openmpi/lib/openmpi:${DYLD_LIBRARY_PATH}

Notice that /Users/gorkiana/Programs/install… is for my own computer, my username is gorkiana, so you should put your own username instead of gorkiana. Save it with control+x+s and exit with control+x+c.Now run your updated bash_profile:

9
. ~/.bash_profile

Now you should have a properly working openMPI. To check if in fact it is, move inside the examples directory:

10
cd examples

And make all the example programs:

11
 make all

Run some of the examples, for example:

12
 mpirun -n 2 hello_c

You should get something like this as output:

13
Hello, world, I am 0 of 2
14
Hello, world, I am 1 of 2

If you get this you have a well installed OpenMPI! Next step.BoostI installed version version 1.4.0. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:

1
wget http://downloads.sourceforge.net/project/boost/boost/1.40.0/boost_1_40_0.tar.gz?use_mirror=kent

After that you must extract the contents of the archive, for that do:

2
tar xvf boost_1_4_0.tar.gz

Move to the extracted directory:

3
cd boost_1_4_0

Run the configuration script:

4
./bootstrap.sh --prefix=~/Programs/install/boost_1_4_0

Edit the file ./user-config.jam:

5
emacs ./user-config.jam

Add the following line: using mpiSave and exit with control+x+s and control+x+c.Build Boost and install it:

6
./bjam install

Now you just need to add some directories to the environment variables by editing your .bash_profile file. Type:

6
emacs ~/.bash_profile

And add the following lines:

# Set up environment variable for boost_1_4_0export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/lib:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/boost/include:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/boost:${LD_LIBRARY_PATH}export DYLD_LIBRARY_PATH=/Users/gorkiana/Programs/install/boost_1_4_0/lib:${DYLD_LIBRARY_PATH}

Save and exit with: control+x+s and control+x+c.You should now have a working installation of Boost! Next step…PETScI installed version version 2.3.3. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:

1
cd ~/Programs/src
2
wget http://ftp.mcs.anl.gov/pub/petsc/software_old/petsc-2.3.3.tar.gz

After that you must extract the contents of the archive, for that do:

2
tar xvf petsc-2.3.3.tar.gz

Move to the extracted directory:

3
cd petsc-2.3.3-p15

Now you need to set up some environment variables for PETSc:

4
export PETS_DIR=~/Programs/src/petsc-2.3.3-p15
5
export PETS_ARCH=macosx

Run the configuration program:

6
python ./config/configure.py --prefix=~/Programs/install/petsc-2.3.3 --with-blas-lapack-lib="-framework vecLib" --with-mpi-dir=~/Programs/install/openmpi/ --with-shared=1 --with-debugging=0

This says that one should use the vecLib LAPACK and BLAS libraries, the openmpi installation that we just did, generate shared libraries and don’t build debugging libraries, that is, build optimized libraries. Good for production code, faster.Now build it:

7
make all

VERY IMPORTANTYou should see a lot of output. When it finishes you should check if there was any error in the end stating that it was unable to make the shared libraries. You can also check if you have any .dylib files (shared libraries) in the directory ~/Programs/src/petsc-2.3.3-p15/lib/macosx. Just type:

8
ls ~/Programs/src/petsc-2.3.3-p15/lib/macosx | grep .dylib

If you get several files, than you are ok, if not, then you need to do the following. This is very important since if you do not have this files, you are stuck in this step and you are unable to build deal.II. This was what took me a lot of time to solve. Thank you Wendy Mason from the Underworld project for the helpful solution!If you do not have the dylib files you need to edit the file ~/Programs/src/petsc-2.3.3-p15/bmake/common/rules.shared.based, doing:

9
emacs ~/Programs/src/petsc-2.3.3-p15/bmake/common/rules.shared.based

Search for a line where there is something like shared_darwin8: shared_darwin7 and add the following line after that one:

10
shared_darwin9: shared_darwin7

Save the file and exit with control+x+s and control+x+c.Make the shared libraries with:

11
make PETSC_ARCH=macosx shared

Now this should work and you should have the shared libraries. Redo:

12
ls ~/Programs/src/petsc-2.3.3-p15/lib/macosx | grep .dylib

And confirm that in fact you have the .dylib files you need.Just install it:

13
make install

Now you just need to add some directories to the environment variables by editing your .bash_profile file. Type:

14
emacs ~/.bash_profile

And add the following lines:

# Set up environment variables for pets-2.3.3export PATH=~/Programs/install/petsc-2.3.3/bin:${PATH}export LD_LIBRARY_PATH=~/Programs/install/petsc-2.3.3/lib/macosx:${LD_LIBRARY_PATH}export LD_LIBRARY_PATH=~/Programs/install/petsc-2.3.3/include:${LD_LIBRARY_PATH}export PETSC_DIR=~/Programs/install/petsc-2.3.3export PETSC_ARCH=macosx

Save and exit with: control+x+s and control+x+c.Run you new bash_profile:

15
. ~/.bash_profile

You should now have a working installation of PETSc! Next step.deal.III installed version version 6.2.1. You can download it from here. You can either download it from the browser and put it inside your ~/Programs/src folder or you can go to the terminal and type:

1
cd ~/Programs/src
2
wget http://www.dealii.org/download/deal.nodoc-6.2.1.tar.gz

After that you must extract the contents of the archive, for that do:

3
tar xvf deal.nodoc-6.2.1.tar.gz

Move to the extracted directory:

4
cd deal.II

Run the configuration script:

5
./configure CC=mpicc CXX=mpicxx --with-boost-include=/Users/gorkiana/Programs/install/boost_1_4_0/include/boost --with-boost-lib=/Users/gorkiana/Programs/install/boost_1_4_0/lib LIBS="-framework vecLib"

Notice that one has to give the MPI compilers no the default ones. If you do not do this, then you will get an error stating that it cannot find some MPI functions. Also you need to give Boost directories and LAPACK and BLAS connected to vecLib, the Apple provided optimized version of LAPACK and BLAS.The configuration process should work fine, after this you just need to build:

6
make all

You should now have a working installation of deal.II.

del.icio.us Slashdot Digg Technorati Google StumbleUpon

Installing Trilinos in Mac OSX 10.5.7

Thursday, September 10th, 2009

To get Trilinos to work it is necessary to get it from here and compile it.In order for the compilation to be successful it is needed a c compiler, a c++ compiler and a fortran compiler. One set of these compilers is given by the gcc bundle. If you install Xcode from Apple you will get gcc and g++ but not gfortran. To get gfortran you can use the one given by macports. Having downloaded Trilinos, you must unpack it. Now, inside the root dir of the unpacked Trilinos tree you should create a directory for you build, even if you just plan on making one build, this is always good. I name it OSX_SINGLE, and move inside it, doing:

1
mkdir OSX_SINGLE
1
cd OSX_SINGLE

Now inside it you should run config, but running config with no special settings gives rise to problems. Hence you should use the following:

1
../configure --cache-file=config.cache --prefix=/usr/local/trilinos-8.0.8-serial CC=/usr/bin/gcc CXX=/usr/bin/g++ F77=/usr/local/bin/gfortran --with-libs="-framework vecLib" --with-ldflags="-Wl,-multiply_defined -Wl,suppress" --enable-amesos --enable-epetra --enable-anasazi --enable-aztecoo --enable-examples --enable-didasko --enable-teuchos --enable-triutils --enable-galeriD

Doing this it should result in a good configuration for make.After this Trilinos is now able to be compiled. To do that you should run:

1
make everything

And then if everything was compiled correctly you should install it, with sudo:

1
sudo make install

After this you should have a working Trilinos installation.

del.icio.us Slashdot Digg Technorati Google StumbleUpon

Backing up a mediawiki wiki

Friday, February 22nd, 2008

Have been filling my wiki with lots of things. Since the data is quite important: I cannot afford to loose it, I must arrange some kind of backup scheme for it. I Googled a lot and found many disperse things that, now, I try to put all together in what I think is a complete solution for the problem and quite general and simple.

For this I assume the following:

  1. ftp.server.of.wiki : is the url of the ftp server where your wiki is stored
  2. ftp_username : the username to access ftp.server.of.wiki
  3. ftp_username_password : the password for ftp_username
  4. remote_path_to_wiki : is the path, from the root of your ftp server (the ftp.server.of.wiki), to your wiki
  5. local_path_to_wiki_database_backup : is the path to the local directory where you want to store your wiki database backup
  6. local_path_to_wiki_dir_backup : is the path to the local directory where you want to store you wiki directory backup
  7. wiki_database_name : the name of your wiki database
  8. wiki_database_username : the username you configure to access the wiki database
  9. database_user_password : the password for the user wiki_database_username
  10. wiki.database.server : the url of the database server of you wiki database
  11. database_backup_filename : the name of the file to where you want to save the backup of you database
  12. you are using mysql

Let us do this by steps:

  1. database backup
  2. wiki files backup
  3. automate backup

1- Database backup

To backup the database one just needs to use the command mysqldump. This command is available in windows and in linux, so that you can do this in both systems. Do this by simply typing:

1
mysqldump -uwiki_database_username -hwiki.database.server -pdatabase_user_password wiki_database_name > database_backup_filename.sql

If this ran correctly now you should have a file with the whole SQL commands to restore your database.

2- wiki files backup

To backup you wiki files you have many options, one is to use rsync but that is not possible always, as happened to me, where my host did not allow me to use it. So my option was ftp. I searched on the internet and I found lftp which is better than ftp because it really assures you that the transfer occurred and you can use the mirror command. For this we just need to type:

1
lftp -u ''ftp_username,ftp_username_password" -e "mirror remote_path_to_wiki local_path_to_wiki_dir_backup" ftp.server.of.wiki

This command will copy everything. You could used instead the following command just just copies the new files:

1
lftp -u ''ftp_username,ftp_username_password" -e "mirror --only-newer remote_path_to_wiki local_path_to_wiki_dir_backup" ftp.server.of.wiki

I also got some problems with empty directories, with the v.3.0.6 of lftp. Then installed the latest version, the v.3.6.3 and everything was ok, so make sure you have the last version.

3- Automate backup

Doing this everyime you want to backup is ok, but if you are like me, you forget to do it regularly or you will end up waking in the night thinking: “F#$%k! I haven’t done a backup for 3 weeks…”. So, for this I decided that I must automate the process of backup up. I use cron (or crontab. Let us first set up a file that sets up the cron jobs, that is the commands we want to execute regularly.

I am a python fan so I made a python script that automates both processes I have just described above. I will not explain how it works, just trust that when you run the python script I put next, say it is called wiki_backup.py, by typing python wiki_backup.py it performs the previous operations. So you just need to copy paste this code to a file and name it, wiki_backup.py and put it wherever you want.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#! /usr/bin/python
###############################################################################
#
#   Script that makes the backup of a mediawiki wiki located
#   at a remote host. To do it, it makes a backup of:
#      1- database
#      2- wiki directory
#
#   INPUTS:
#       database_username: username of the wiki backup
#       database_name: name of the wiki database
#       database_username_password: password for the user database_username
#       database_server: the url of the database server that hold the wiki database
#       ftp_server: the url of the ftp server where the wiki is stored
#       ftp_username: the username to access the ftp server where the wiki is stored
#       ftp_password: the password for the ftp_user
#       backup_directory_name: the name of the directory where you want to backup
#                              your wiki. This directory is created in your home dir
#       wiki_name: the name of your wiki, used to create some of the backup files.
#
#   RESULTS:
#      Everytime the script is run, a file named:
#         wiki_name_YYYYMMDD.sql
#      is created, with YYYY the year, MM the month and DD the day.
#      This file will be stored in the subdirectory under backup_directory_name
#      named database_backups.
#
#      Also all the content of the remote dir where your wiki is is stored
#      inside backup_directory_name in a folder named wiki_files_backup.
#      This backup is incremental.
#
###############################################################################
 
###############################################################################
#
# User input data
#
database_username = "insert_here"
database_name = "insert_here"
database_username_password = "insert_here"
database_server = "insert_here"
ftp_server = "insert_here"
ftp_username = "insert_here"
ftp_password = "insert_here"
wiki_remote_dir = "insert_here"
backup_directory_name = "insert_here"
wiki_name = "insert_here"
#
###############################################################################
 
# import the necessary modules
 
# module for running operating system commands
import os
# module to have time operations like, getting the time
import time
 
# create the directory structure where to store all the backup files:
#
# ---- ~/
#         |
#         |__backup_directory_name
#                 |
#                 |__database_backups
#                 |__wiki_files_backup
#
 
# check if backup_directory_name exists, if not, create it
 
# get the home directory.
try:
	#If in WINDOWS USERPROFILE exists
	home_dir = os.environ["USERPROFILE"]
except KeyError:
	# if an error occurs, trap the error and use
	# HOME instead
	home_dir = os.environ["HOME"]
 
# make the root dir for the backups
root_dir_backup = os.path.join(home_dir, backup_directory_name)
 
# check if root_dir_backup exists
if not os.path.exists(root_dir_backup):
	# if it does not exist create it
	os.mkdir(root_dir_backup)
# if exists, check if it is a directory
elif not os.path.isdir(root_dir_backup):
	# if it is not, create it
	os.mkdir(root_dir_backup)
 
# now generate the subdirectories names
database_backups_dir = os.path.join(root_dir_backup, "database_backups")
wiki_files_backup_dir = os.path.join(root_dir_backup, "wiki_files_backup")
 
# check if the directories exist and create them if not, as before
#database_backups_dir
if not os.path.exists(database_backups_dir):
	# if it does not exist create it
	os.mkdir(database_backups_dir)
# if exists, check if it is a directory
elif not os.path.isdir(database_backups_dir):
	# if it is not, create it
	os.mkdir(database_backups_dir)
# wiki_files_backup_dir
if not os.path.exists(wiki_files_backup_dir):
	# if it does not exist create it
	os.mkdir(wiki_files_backup_dir)
# if exists, check if it is a directory
elif not os.path.isdir(wiki_files_backup_dir):
	# if it is not, create it
	os.mkdir(wiki_files_backup_dir)
 
# now that the directory structure is created, generate the
# filename for the database backup, using the current time and the
# wiki name: wiki_name_YYYYMMDD.sql
 
# get the local time
localtime = time.localtime()
database_backup_filename = "%s_%02d%02d%02d.sql" % (wiki_name, localtime[0], localtime[1], localtime[2])
database_backup_filename_complete_path = os.path.join(database_backups_dir, database_backup_filename)
 
# give info to the user
print "making backup of wiki database:"
print "database: %s" % database_name
print "server: %s" % database_server
print "username: %s" % database_username
 
# backup the database from the remote server
command = "mysqldump -u%s -h%s -p%s %s > %s" % (database_username, database_server, database_username_password, database_name, database_backup_filename_complete_path)
os.system(command)
 
# give info to the user
print ""
print "making backup of wiki files:"
print "ftp server: %s" % ftp_server
print "remote dir: %s" % wiki_remote_dir
print "username: %s" % ftp_username
 
# backup the wiki directory from the remote dir
command = "lftp -u \"%s,%s\" -e \"mirror --only-newer %s %s\" %s" % (ftp_username, ftp_password, wiki_remote_dir, wiki_files_backup_dir, ftp_server)
os.system(command)

After, allow that it is executed: doing chmod +x wiki_backup.py on the directory where the file is.

Let us first recall how a cron jobs file is made. Each line of a cron jobs file is a job you want to perform regularly and in that line you specify the regularity and the command to execute, like this:

1
[min] [hour] [day of month] [month] [day of week] [program to be run]

where:

  • [min]: the minutes at which the program should run. 0-59. Do not set as * or the program will be run once a minute.
  • [hour]: the hour at which the program should run. 0-23, * for every hour
  • [day of month]: the day of the month at which the program should run. 1-31, * for every day.
  • [month]: the month at which the program should run. 1-12, * for every month.
  • [day of week]: the day of the week at which the program should run. 0-6 where Sunday=0, Monday=1, …, Saturday=6 and * for every day of the week.
  • [program]: the program to be executed. Include full path information.

An example:

1
0,15,30,45 * * * * /usr/bin/foo

where:
To run the program /usr/bin/foo every 15 minutes on every hour, day of the month, month and day of the week. It will run each 15 minutes for as long as the machine is running.Ok, you get the point. For more than you cron job, just put one job at each line of a cron job file.

Let us continue with our mission.

First create the text file with the cron jobs, say cron.wiki. You can do it with any text editor (gedit, kate, emacs, vim, pico, whatever). This file should contain, if you want the backup procedure to run at 03:00 in the morning, everyday of the month, month and day of the week :

0 3 * * * /absolute/path/to/python/script/wiki_backup.py

Now, on a shell add the cron jobs using crontab:

1
crontab cron.wiki

Check if it was added correctly:

1
crontab -l

If your job appears, then everything is ok and you wiki will be backuped everyday at 03:00, now you can relax!

In the near future I will show how to restore a wiki, from the files we are backing up.

del.icio.us Slashdot Digg Technorati Google StumbleUpon

Mounting a remote ssh filesystem using sshfs on Ubuntu

Saturday, February 2nd, 2008

I am working on a Linux computer at the University with a RedHat Entreprise distribution. There I have all my work that:

  1. I wish to have as backuped as possible;
  2. I wish to have easily accessible from my laptop, to upload and download.

I looked for ways to do it and I found sshfs. In this way, as I will show you, whenever I log in to my laptop, with an internet connection available, I have a virtual folder where I have a seamless access to all the files on my pc at the University. This is how I did it:

  1. Enabled the Multiverse on the Synaptics software sources. Went to System–> Administration –> Software sources, then on the Ubuntu software tab, checked the fourth option (Multiverse).
  2. Installed sshfs:
    sudo apt-get install sshfs
  3. Once installed, changed the permissions so that I could mount it as normal user:
    sudo chmod +x /usr/bin/fusermount
  4. Made a mount point directory on my laptop that points to the directory I am mounting on the other machine. In this case I created a directory named lraero19 (which is the name of my computer at the university) on the /media directory:
    sudo mkdir /media/lraero19
  5. Then changed the owner to me:
    sudo chown gorkiana /media/lraero19
  6. Afterwards I had to add my user to the group “fuse” so that I could use it. For that I typed:
    sudo adduser gorkiana fuse

    Then I had to logout and login back again so that the change took effect.

  7. Mounted the remote drive with sshfs. For this I typed in:

    sshfs my_user_name@ip_at_university:/the_directory_to_mount /media/lraero19

  8. To unmount I just type:
    fusermount -u /media/lraero19

Since I have to do this every time I logged in, I decided to automate the process. For that I needed first to get rid of the password prompt. Hence I did this:

  1. I had to create a public key on my laptop and copy it to the university computer so that I did not need to type in the password every time. Typed:
    ssh-keygen -t rsa

    (typed enter to the both question since I do not want a password).

  2. Made a directory named .ssh at my home directory at the university computer:
    mkdir /media/lraero19/.ssh

    (now I can do it as if it was a local directory :-) ).

  3. Then chmoded it:
    chmod 700 /media/lraero19/.ssh
  4. Copied the public key to there:
    cat .ssh/id_rsa.pub >> /media/lraero19/.ssh/authorized_keys
  5. Chmoded it:
    chmod 600 /media/lraero19/.ssh/authorized_keys

Then I wanted it to run everytime I logged in to GNOME, for that I just went to Sytem –> Preferences –> Sessions, then at the startup programs tab just added one more, with the command:

sshfs my_user_name@ip_at_university:/the_directory_to_mount /media/lraero19

Finally I had to get a way of unmounting the drive when I logged out. After many hours googling I found a solution! Edited the file: /etc/gdm/PostSession/Default and added the following line before the exit 0 line:

fusermount -u /media/lraero19

del.icio.us Slashdot Digg Technorati Google StumbleUpon

LaTeX on mediawiki on a shared host

Wednesday, January 30th, 2008

For a couple of weeks I have been trying hard to put my NereidesWiki to work on my website hosted at ixwebhosting, which is a shared host.

The idea behind this wiki was that it could be a place to start collecting ideas and things that I learn during my phd, so that, in the end, it would be easier to write down the thesis. Since it is a scientific related wiki it is mandatory that it is able to show mathematical expressions. MediaWiki is able to do that making use of texvc, LaTeX, dvips and convert from the ImageMagick software suit, the problem lies in configuring it.

Of course, at the first attempt it did not work and I sent a ticket to the host and they replyed with a kind: “we don’t support 3rd party software”. I was on my own. After googling alot I found that I had to start by putting texvc to work, that ment compiling it for the OS of the host. After too many tickets sent to them and too many live chats with them and with a help of a friend of mine, I managed to compile it. It did not work either. Later they told me they did not hat LaTeX nor dvips installed on the server.

I was about to give up, thinking “why isn’t there a service that one could use instead of going through all this trouble?”. Instead of running it locally on our own server, run LaTeX and dvips remotely on another server. Hopefully I found it: mimeTeX! Very simple to use. Here I show you how to do it, or you can follow the original link here:

  1. Install MediaWiki
  2. Take a backup of your MediaWiki installation.
  3. Find a LaTeX engine:
    1. If you have CGI support on your host install mimeTeX, which can be found at: http://www.forkosh.com/mimetex.html
    2. If you don’t have CGI support, use a public mimeTeX server: http://www.forkosh.dreamhost.com/mimetex.cgi or http://www.forkosh.dreamhost.com/mathtex.cgi (for prettier rendering using mathTeX)
  4. Open Math.php in $WikiPath/includes/Math.php and find this function:

1
2
3
4
5
6
function renderMath( $tex ) {
   global $wgUser;
   $math = new MathRenderer( $tex );
   $math->setOutputMode( $wgUser->getOption('math'));
   return $math->render();
}

Replace it with:

1
2
3
4
5
6
7
8
function renderMath( $tex ) {
   ###Hacking Math.php
   #global $wgUser;
   #$math = new MathRenderer( $tex );
   #$math->setOutputMode( $wgUser->getOption('math'));
   #return $math->render();
   return "<img src="http://blog.palha.org/wp-admin/%5C%22http://your_host/cgi-bin/mimetex.cgi?$tex%5C%22" class="tex" alt="\"LaTex:" />";
}

Where http://your_host/cgi-bin/mimetex.cgi is the URL of your mimeTeX installation or the public one. I used a public one, and it works, at least with MediaWiki v1.11.1. Note that you must have texvc compiled, but that is not very difficult to solve.

del.icio.us Slashdot Digg Technorati Google StumbleUpon