Matteo Mattei

Hello, my name is Matteo Mattei and this is my personal website. I am computer engineer with a long experience in Linux system administration and web software development.

linkedin rss twitter google+ github facebook

Install yum and php-pear on Centos 5

Virtual server like Aruba virtual servers are configured with Centos without yum and without php-pear. Today I have done an assistance to a server of my customer that needed pear installation. It is quite simple to make all work but I don’t understand why Aruba’s staff have not decided to include yum in their own default configuration server…

Shall we start installing yum:

mkdir /root/matteo && cd /root/matteo
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/gmp-4.1.4-10.el5.i386.rpm
rpm -Uvh gmp-4.1.4-10.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/readline-5.1-3.el5.i386.rpm
rpm rpm -Uvh readline-5.1-3.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-2.4.3-27.el5.i386.rpm
rpm -Uvh python-2.4.3-27.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/libxml2-2.6.26-2.1.2.8.i386.rpm
rpm -Uvh libxml2-2.6.26-2.1.2.8.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/libxml2-python-2.6.26-2.1.2.8.i386.rpm
rpm -Uvh libxml2-python-2.6.26-2.1.2.8.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/expat-1.95.8-8.3.el5_4.2.i386.rpm
rpm -Uvh expat-1.95.8-8.3.el5_4.2.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
rpm -Uvh python-elementtree-1.2.6-5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/sqlite-3.3.6-5.i386.rpm
rpm -Uvh sqlite-3.3.6-5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm
rpm -Uvh python-sqlite-1.1.7-1.2.1.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/elfutils-0.137-3.el5.i386.rpm
rpm -Uvh elfutils-0.137-3.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/rpm-python-4.4.2.3-18.el5.i386.rpm
rpm -Uvh rpm-python-4.4.2.3-18.el5.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/m2crypto-0.16-6.el5.6.i386.rpm
rpm -Uvh m2crypto-0.16-6.el5.6.i386.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/python-urlgrabber-3.1.0-5.el5.noarch.rpm
rpm -Uvh python-urlgrabber-3.1.0-5.el5.noarch.rpm
wget http://mirror.centos.org/centos-5/5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
rpm -Uvh yum-3.2.22-26.el5.centos.noarch.rpm
yum -y update

Now it’s time to install php-pear:

yum install php-pear*

Ok, in every virtual-host of Plesk (/var/www/vhosts/example.com/conf/httpd.include), there is the directive open_basedir that must be configured in the right way adding the pear path:

php_admin_value open_basedir "/var/www/vhosts/example.com/httpdocs:/tmp:/usr/share/pear:/local/PEAR"

We must also configure pear in /etc/php.ini

include_path=".:/usr/share/pear:/local/PEAR/"

At the end you shall restart Apache:

/etc/init.d/httpd restart

Hide file and directory in Apache disabling browsing

If you want to disable file and directory browsing on your Apache web server in order to prohibit that every users can view the content of a directory (if noindex.php/index.html is present) you need to modify the Apache configuration a little or add a new statement in .htaccess file.

I will show you how to do in both cases:

  1. Apache configuration: httpd.conf/virtual-hosts
    Edit your virtualhost adding these rows:
<Directory "/home/httpd/html/mydomain/files">
    Options -Indexes
</Directory>
  1. .htaccess
    Add in the .htaccess file this row:
Options -Indexes

In the first case you need to restart apache server.


Script to remove trailing tilde (~) from temporary files

Using kate as similar text editors, temporary files that have been saved present an annoying trailing tilde that I personally consider useless. I am used to be careful when I edit a file, so I don’t need the backups. For this reason I developed this mini script in bash to remove temporary files from a folder.

#!/bin/bash
rm `find $1 | grep "~$"`

I called the above file rmm and I put it in /usr/bin/ folder. To use it, just place in the folder you have files with trailing slashes and execute it:

$ rmm .

Or directly passing the folder as the first argument:

$ rmm /home/matteo/src

This script is trivial and can be obviously improved. If you want to contribute I will be happy to add your improvements.


How to record video streaming

I often see beautiful streaming videos in a variety kind of formats and some people that are trying to grab those videos without any concrete result. I want to share with you how to capture those streams and convert them in a more usable AVI format.

Well… the only thing to do is open a shell on Linux and check if you have installed mplayer, then run this simple command

$ mplayer "mms://url" -dumpstream -dumpfile video_out.avi

Where:

  • mms://url is the URL of the video stream.
  • video_out.avi is the output of the recorded video.

That’s all.

Note:
This trick is only available for streams play-ables with mplayer. For sites like Youtube or similar that encode video in flash format, you can’t do it.

Disclaimer: Some sites licenses cannot allow to grab any video. So, please read carefully sites licenses before record any streams.