Category Archives: centos

yum segmentation fault in centos

After an upgrading with yum program, yum will end with segmentation fault.

Last link about libz is the cause:
-rwxr-xr-x 1 root root  75028  9 gen  2007
-rwxr-xr-x 1 root bin   96572  8 nov  2010
-rw-r--r-- 1 root bin  101462  8 nov  2010 libz.a
lrwxrwxrwx 1 root root     13  8 apr  2011 ->
lrwxrwxrwx 1 root root     13  8 apr  2011 -> need a different link:
lrwxrwxrwx 1 root root     13  8 apr  2011 ->

Reference: yum fails with segfault after source zlib upgrade

Set TimeZone on Centos

CentOS update breaks another thing – the logwatch perl timezone manipulation. The exact error message is:
ERROR: Date::Manip unable to determine TimeZone.

Execute the following command in a shell prompt:
perldoc Date::Manip
The section titled TIMEZONES describes valid TimeZones and where they can be defined.

You could fix it modify /etc/localtime. You could use tzconfig command line and follow its questions or:
cp /usr/share/zoneinfo/Europe/Rome /etc/localtime
If your localtime is different, you could choose your zoneinfo in /usr/share/zoneinfo/.


PHP PEAR installation and configuration

PEAR is short for “PHP Extension and Application Repository” and is pronounced just like the fruit. The purpose of PEAR is to provide:

  • A structured library of open-source code for PHP users
  • A system for code distribution and package maintenance
  • A standard style for code written in PHP, specified here
  • The PHP Extension Community Library (PECL), see more below
  • A web site, mailing lists and download mirrors to support the PHP/PEAR community

There is not important what it is your OS: you could download to begin installation.
mv go-pear go-pear.php
php go-pear.php

or simply:
aptitude install php-pear (Debian / Ubuntu)
yum install php-pear (Fedora / Centos)

Verifying the include path
To use PEAR and PEAR compatible packages in your applications, you normally include them into your PHP scripts using require_once(). For this to work, PEAR’s php_dir must be a part of PHP’s include path.
1. First, check where PEAR installs .php files:
pear config-get php_dir
mine output is:
This directory will contain System.php.
2. Now it’s time to find which configuration file is used by your PHP installation. On command line, execute:
php --ini | grep Loaded
mine output is:
Loaded Configuration File: /etc/php.ini
To see which php.ini is used by PHP on your web server, create a file with only as the contents, and save it in your local web root as check_php.php. Open the file in your browser as http://localhost/check_php.php, to find the path to the php.ini file your web server is using.
3. include_path about php.ini must include php pear directory:
grep include_path /etc/php.ini | egrep "^[^;]"
mine output is:
include_path = ".:/usr/local/php/pear/"
If your include_path does not contain php pear directory, then you must add it modifying php.ini.
Modifying php.ini
To get PEAR working properly, you need to adjust PHP’s include_path. After you found php.ini, open it in an editor.
Search for the line include_path.
Now that you found it, you probably will see a semicolon ; at the beginning. This means the line is a comment. Add a new line below it.
In this line, write:
Depending on your operating system, add a : (Unix/Linux/FreeBSD/Mac OS X) or a ; (Windows) after the dot. Add PEAR’s php_dir after it. (The directory System.php is located in!)
The result should look like that:
; Unix

; Windows

Checking if PEAR works
Now that this is done, try including a file. Create a new check_pear.php file with the following contents:

require_once 'System.php';

System.php is shipped with every PEAR installation and thus should be on your computer, too. Open the file with the browser from your web server, and also try it on command line:
php check_pear.php
The only output should be
A message like:
Warning: require_once(System.php): failed to open stream:
No such file or directory in /path/to/check_pear.php on line 2

means that your include path is not correct. (So go and fix it!)
Installing packages
After getting PEAR working on your machine you most likely want to install some packages. This guide shows people new to the PEAR command line installer how to get started. The general command to install a PEAR package named “foo” is
pear install foo
Typing this and pressing return, the package will be downloaded and installed on your computer. It does not matter if you write the package name in lowercase, UPPERCASE or MixedCase – the installer will find the package by lowercasing the name.
When a package is already installed, you will get the following message:
pear install foo
Output is:
Ignoring installed package pear/foo
Nothing to install

This happens even if there is a newer version of the package! The correct command to upgrade to the lastest version is
pear upgrade foo
Output is:
upgrade ok: channel://
If the package already has the lastest version, you will get a message similar to the following:
Ignoring installed package pear/Foo
Nothing to upgrade

In the case you deleted some file and really really want to re-install the package, you have two choices:

  • Uninstall the package, and reinstall it afterwards
  • Force the installation

Forcing an command should only be done when you absolutely know what you are doing – you might in some circumstances break PEAR otherwise. Forcing something should always be the last option.
pear install -f foo
pear upgrade -f foo

Unstable alpha/beta packages
Now and then, you will get error messages like

Failed to download pear/foo within preferred state "stable",
latest release is version 0.1.2, stability "beta",
use "channel://" to install
Cannot initialize 'channel://', invalid or missing package file
Package "channel://" is not valid
install failed

Reason for this is that PEAR by default installs stable packages only. When a package is in state devel, alpha or beta it will refuse to install them. You can easily persuade it by adding either the version number or the stability you are willing to accept:
pear install Foo-beta
pear install Foo-alpha

You can also install a specific version, or upgrade to a specific version regardless of the state:
pear install Foo-1.2.3
pear upgrade Foo-1.2.3

Verifying the open basedir
It may happen that from the command line php pear works and via browser no. In the apache configuration file of domain may need to add:

php_admin_value open_basedir "/var/www/"
php_admin_value include_path ".:/usr/local/php/pear/"

Reference: about PEAR, getting started, installing packages, checking if PEAR works,


mytop – display MySQL server performance info like ‘top’

mytop [options]

mytop -u mysqluser -p mysqlpassword -d database

Mytop has started to break on RHEL or CentOS. It appears that some of the perl modules have change.d
There error is:
Error in option spec: "long|!"

The fix for this is to edit the mytop script and comment out the line containing long|!
nano /usr/bin/mytop
Run a search for long|! and comment out the following line:
"long|!" => \$config{long_nums},
Start mytop and you should be fine!


Installing msttcorefonts

If you need MS fonts installed in our Linux Operating System, in order to look at the documents in the same way they are looking at it.
on Debian / Ubuntu
sudo aptitude install msttcorefonts
on Fedora / Centos
Install the software needed
sudo yum install rpm-build cabextract
download cabextract package here
Download the specs to build the RPM
Build the RPM
rpmbuild -ba msttcorefonts-2.0-1.spec
Install the RPM
rpm -ivh msttcorefonts-2.0-1.noarch.rpm
Reload xfs
/sbin/service xfs reload
Now the msttcorefonts are installed and available. Look:
yum list msttcorefonts


lighthttpd h264 streaming module installation on CentOS

rpm -ivh lighttpd-1.4.28-1.el5.rf.i386.rpm
rpm -ivh lighttpd-fastcgi-1.4.28-1.el5.rf.i386.rpm
rpm -ivh --nodeps lighttpd-mod_h264_streaming-1.4.28-1.i386.rpm

Edit file /etc/lighttpd/lighttpd.conf and modify server.use-ipv6 value in disable. I f you could dedicate one IP, uncomment server.bind and change localhost with IP dedicated.
Edit file /etc/lighttpd/modules.conf and:

  • comment all modules in server.modules
  • in server.modules, add line:
  • below server.modules, add lines:
    h264-streaming.extensions = ( ".mp4", ".f4v" )
    h264-streaming.buffer-seconds = 10

Start your new web server:
service lighthttpd start
Add web server in runlevel:
chkconfig --add lighttpd
For testing purposes we recommend a tool like wget, or curl):

  • upload one f4v video to the document root of your website:
    wget sample.f4v
    cp sample.f4v /srv/www/lighttpd/
  • download the full file:
    wget -O test.f4v "http://localhost/sample.f4v"
  • download file with specify start time:
    wget -O test.f4v "http://localhost/sample.f4v?start=45.5"
    This saves a file (test.f4v) on your local disk that will have the first 45.5 seconds removed from the original (sample.f4v) video

You can use your favorite player to see if worked okay.

Reference: installation and testing

Red5 installation


  • Download and Install Java. RED5 server depends on Java. CentOS 5.3 comes with OpenJDK 1.6 and install it using yum.
    yum -y install java-1.6.0-openjdk java-1.6.0-openjdk-devel
  • Download and Install Ant (Apache Project). Ant will need to compile RED5 server code. Ant comes in binary form, so just download and install it in /usr/local directory.

    cd /usr/src
    tar jxvf apache-ant-1.8.0-bin.tar.bz2
    mv apache-ant-1.8.0 /usr/local/ant
  • Export Variables for Ant and Java

    export ANT_HOME=/usr/local/ant
    export JAVA_HOME=/usr/lib/jvm/java
    export PATH=$PATH:/usr/local/ant/bin
    export CLASSPATH=.:$JAVA_HOME/lib/

    Also export these variables in /etc/bashrc to become available for every user login or for any terminal opens.

    export ANT_HOME=/usr/local/ >> /etc/bashrc
    export JAVA_HOME=/usr/lib/jvm/ >> /etc/bashrc
    export PATH=$PATH:/usr/local/ant/ >> /etc/bashrc
    export CLASSPATH=.:$JAVA_HOME/lib/classes. >> /etc/bashrc
  • Download and Install RED5 Server. Here the latest version available for RED5 is 0.7 on site but download from google code using svn as the tarball of 0.7 on site is missing some of the files.

    cd /usr/src
    svn checkout red5
    mv red5 /usr/local/
    cd /usr/local/red5
    ant prepare
    ant dist
  • you will see a ton of lines, but you should get at last


    this mean its install and now copy the conf directory from dist/ and test the red5 installation.

    cp -r dist/conf .

    If it shows Installer service created in the last then everything is fine here, press ctrl+c and move to next step to create init script.


  • Before beginning this make sure you are running these commands as root. Install Subversion:
    apt-get install subversion
  • Install tools to build your own Debian packages:

    apt-get install dpkg-dev
    apt-get install debhelper
    apt-get install dh-make
    apt-get install devscripts
    apt-get install fakeroot
  • Install Java (see this tutorial for more info):
    apt-get install java-package
  • Install Apache Ant 1.7:

    gzip -d xf apache-ant-1.7.0-bin.tar.gz
    tar -xf apache-ant-1.7.0-bin.tar
    cd apache-ant-1.7.0
    mv apache-ant-1.7.0 /usr/local/ant
    export ANT_HOME=/usr/local/ant
  • Once Java and Ant are all set up you simply download the latest development version of Red5 to your box.
    svn co red5-trunk

    That will create a folder in your current directory called red5-trunk.
  • Navigate to the red5-trunk directory and run
    That will build the project on your machine.
  • At this point you will need to create a red5 directory in the /usr/local/red5 directory.

    mkdir /usr/local/red5
  • Then you will want to copy the contents of the dist(distribution) folder to /usr/local/red5 like so
    cp -R red5-trunk/dist/* /usr/local/red5/
  • We need need to fix the permissions on the file:
    cd /usr/local/red5
    chmod 755
  • To run the server you have a few options using the file. Run the server by either running
    sh &
    ./ &

    This will start the Red5 service manually.
  • Verify the correct ports are being bound to:
    netstat -ant


sudo apt-get update
sudo apt-get install subversion
sudo apt-get install java-package
sudo apt-get install sun-java6-jdk
sudo apt-get install ant
mkdir -p ~/svn/red5
cd ~/svn/red5
svn checkout red5-read-only
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export ANT_HOME=/usr/share/ant/
cd ~/svn/red5/red5-read-only
sudo mkdir /usr/share/red5
cd ~/svn/red5/red5-read-only/dist
sudo cp -R * /usr/share/red5/
cd /usr/share/red5
sudo chmod 755
/usr/share/red5/ &

Digit on browser: http://localhost:5080 and good luck!

Init Script
Now we will create init script for red5 to start, stop and restart easily.
cp red5.txt /etc/init.d/red5
chmod 755 /etc/init.d/red5


MaxClients directive

The MaxClients directive sets the limit on the number of simultaneous requests that will be served. Any connection attempts over the MaxClients limit will normally be queued, up to a number based on the ListenBacklog directive. Once a child process is freed at the end of a different request, the connection will then be serviced.

For non-threaded servers (i.e., prefork), MaxClients translates into the maximum number of child processes that will be launched to serve requests. The default value is 256; to increase it, you must also raise ServerLimit.

For threaded and hybrid servers (e.g. beos or worker) MaxClients restricts the total number of threads that will be available to serve clients. The default value for beos is 50. For hybrid MPMs the default value is 16 (ServerLimit) multiplied by the value of 25 (ThreadsPerChild). Therefore, to increase MaxClients to a value that requires more than 16 processes, you must also raise ServerLimit.

  • Set it on CentOS server:
    • digit this command line to test how modules are activated:
      httpd -l

    • edit /etc/httpd/conf/httpd.conf and add/modify ServerLimit directive on active module
    • ServerLimit 20000

    • apachectl -t
    • apachectl graceful
    • edit /etc/httpd/conf/httpd.conf and modify MaxClients directive on active module
    • MaxClients 20000

    • apachectl -t
    • apachectl graceful
  • Set it on Debian server:
    • digit this command line to test how modules are activated:
      apache2 -l

    • edit /etc/apache2/apache2.conf and add/modify ServerLimit directive on active module
    • ServerLimit 20000

    • apachectl -t
    • apachectl graceful
    • edit /etc/apache2/apache2.conf and modify MaxClients directive on active module
    • MaxClients 20000

    • apachectl -t
    • apachectl graceful

Reference: apache2

php5 update on CentOS

If you have CentOS v5.2 then you have PHP v5.1.6. Any PHP5 systems need PHP5 > v5.2.
The php-sqlite2 library has a problem to update so that you must delete it:
yum erase php-sqlite2
Now, you have got any solutions:

    Update PHP5 to last stable version and create /etc/yum.repos.d/CentOS-Testing.repo with this content:

    name=CentOS-5 Testing

    Update PHP5 to last beta version and create /etc/yum.repos.d/utterramblings.repo with this content:

    name=Jason's Utter Ramblings Repo

Now, you could update system:
yum update

Reference: and

php-mcrypt installation on CentOS

Updating/Installing mcrypt
If you have php-mcrypt for PHP 5.1.x installed you’ll want to remove it:
Note: Your version number maybe different. Alter below command accordingly.
rpm -e php-mcrypt-5.1.6-15.el5.centos.1
Download php-mcrypt for PHP 5.2.x and install it. You can find a 32-bit php-mcrypt package here FedoraJunkies.
Note: You’ll notice the “–nodeps” flag in the example. When you try to install php-mcrypt without it you get an error that php-common-5.2.6-2.el5s2 is missing even though it is installed.
wget -c
rpm -i --nodeps php-mcrypt-5.2.6-2.i386.rpm

Restart Apache and you should now see mcrypt information on your testing.php page.

System installs library and creates /usr/lib/php5/../
Check if mcrypt.ini file exists or create it in /etc/php5/conf.d and added this one liner: