Centos Howto


Install CentOS

Yep, you will need CentOS 5 from http://www.centos.org


yum install postgresql postgresql-server

Initialize the cluster:

su postgres
initdb -D /var/lib/pgsql/data -E UTF8 --locale=en_US.utf8

Add postgresql to the default runlevel (use e.g. ntsysv tool)
Run postgresql with /etc/init.d/postgresql start

Tweak the database configuration located at /var/lib/pgsql/data/postgresql.conf. You might want to:

  • increase memory — find out how to do this ;-)
  • fsync = Off if you know what you are doing


Memcached is not included in the distro, you can get an RPM e.g. from http://rpm.pbone.net/. Or you can compile it from source. Memcached 1.2.X is recommended.

Set it up to listen on port 11211 (default), protect this port from outer-world (listen on localhost only or set up iptables).

Add memcached to the default runlevel (use e.g. ntsysv tool)
Run memcached with /etc/init.d/memcached start


I hope any Apache 2.X will do fine.

TODO: mod_gzip

Other software


yum install tetex tetex-fonts tetex-dvips tetex-latex ghostscript


ImageMagick is used to:

  • identify (media) files
  • generate thumbnails and scale images
  • convert latex equations to images
yum install ImageMagick

PHP, PEAR, PECL and dependencies

PHP itself

We will try to install the plain php-5.1.6 from the repository and see if it works.

yum install php

Notable configuration tweaks

allow_url_fopen = On


yum install php-pear

PECL + dependencies

Fileinfo and memcache

yum install php-pecl-Fileinfo php-pecl-memcache

And put this into your php.ini


NOTE: make sure that fileinfo can recognize files and output both description and mime type. Try to upload a file and check its record in the database. The problem is with fileinfo not able to find proper mime files in /usr/share/misc/mime.*. In our installation the files were located in /usr/share/file and we had to copy them to /usr/share/misc.

xdiff + libxdiff

Grab libxdiff from here: http://www.xmailserver.org/xdiff-lib.html
Unpack, compile and install. Then install pecl-xdiff

pear install pecl/xdiff

You should also add this to your php.ini:



pear install pecl/apc

You should also add this to your php.ini:


Instead of APC you can also use Eaccelerator.

IMPORTANT: it seems that APC is permanently broken and is segfaulting the webserver under high load. Recommendation: DON'T! Eaccelerator works fine.

Tidy and php-tidy

TidyHTML is used to purify and repaid broken html generated by the parser.

yum install php-tidy

PostgreSQL functions

yum install php-pgsql

Other PHP

yum install php-mbstring

Major tweaks

PHP 5.2.X

The easiest way to upgrade PHP to 5.2.X is to use this repository: http://www.jasonlitka.com/yum-repository/. It is also advised to use newer php-pear.
You can also use a src.rpm instead of binary versions. Like this one: http://www.jasonlitka.com/2007/11/16/upgrading-to-php-525-on-rhel-and-centos/


The problem with complex (with recurrsion?) regular expressions is that they can eat a lot of memory, which can result in sementation fault if pcre wants to use more memory than available. PCRE library uses stock during processing, the trick is to recompile the the pcre lib with --disable-stack-for-recursion — it helps a lot.

Currently we are using PCRE 7.3, you can grab an src.rpm from Fedora dev repository, edit the pcre.spec and compile with rpmbuild -bb pcre.spec.

Broken Xdiff 1.4

The pecl-xdiff library is broken. It uses int when long should be used, which results in faulty parsing of arguments. Now we have a Xdiff fixed (where we needed).

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License