Resources on how to write your own PHP extension

Posted in development on 18/11/2009 by Pedro Padron – Be the first to comment

A few days ago I started to write my first PHP extension, and I have to admit it was a pain in the beginning. Actually it still is, but I’m the one to blame for lacking some C skills. Anyway, my advice is: if you want to write your own extension you’d better have a good reason to do so. Here are some of the most common ones:

  • increase performance
  • change PHP behavior (take a look at these PECL extensions)
  • wrap a C library
  • you are very curious and want to know how to do it anyway

If you still want to give it a try, here are some of the things that helped me along the way:

Maybe I’ll write some posts about this. Maybe.

How to install Ruby 1.8.6 RPM package on RHEL3

Posted in sysadmin on 28/10/2009 by Pedro Padron – 1 Comment

I have to manage a few RHEL3 servers (i386), and since I’m using Puppet in my environment, it would be great to use it in those servers also. However, Puppet requires ruby >= 1.8.1, and RHEL3 ships ruby 1.6.8.

Instead of compiling ruby on the server (quick and dirty), I rebuilt the RPM based on the specs from Fedora 11. The only change I had to make was in the list of build dependencies. Here’s my note in the %changelog section of the specfile:

* Tue Oct 27 2009 Pedro Padron <ppadron@w3p.com.br> - 1.8.6.369-2
- build-deps: XFree86-devel instead of libX11-devel to build in RHEL3

Here’s the source RPM package:

ruby-1.8.6.369-2.src.rpm

To rebuild it:

$ rpmbuild --rebuild --define 'dist .el3' ruby-1.8.6.369-2.src.rpm

Here’s the list of packages that will be generated:

ruby-1.8.6.369-2.el3.i386.rpm
ruby-devel-1.8.6.369-2.el3.i386.rpm
ruby-docs-1.8.6.369-2.el3.i386.rpm
ruby-irb-1.8.6.369-2.el3.i386.rpm
ruby-libs-1.8.6.369-2.el3.i386.rpm
ruby-mode-1.8.6.369-2.el3.i386.rpm
ruby-rdoc-1.8.6.369-2.el3.i386.rpm
ruby-ri-1.8.6.369-2.el3.i386.rpm
ruby-tcltk-1.8.6.369-2.el3.i386.rpm

If you are interested in installing puppet as well, you will also need augeas and it’s ruby bindings:

augeas-0.5.0-2.src.rpm
ruby-augeas-0.3.0-1.src.rpm

And again:

$ rpmbuild --rebuild --define 'dist .el3' augeas-0.5.0-2.src.rpm
$ rpmbuild --rebuild --define 'dist .el3' ruby-augeas-0.3.0-1.src.rpm

Rebuilding Webalizer RPM to change the default language

Posted in sysadmin on 13/10/2009 by Pedro Padron – Be the first to comment

Quoting the official Webalizer website:

The Webalizer is a fast, free web server log file analysis program. It produces highly detailed, easily configurable usage reports in HTML format, for viewing with a standard web browser.

By default, the reports generated by Webalizer are in English, and there is no way to change this after it is installed. This is because the language files are statically linked in it’s source code, therefore you need to recompile it if you want to change it’s language.

However, if you installed Webalizer from an RPM package, it’s lame to just recompile it and copy the webalizer binary (if you use Plesk, it is what Parallels suggests) since it would break package verification with rpm -V webalizer. Wouldn’t it be better if your RPM package already provided the software in the desired state? Let’s see how this could be done…

read more »

Facter + Puppet: Writing custom facts to manage Plesk servers

Posted in sysadmin on 25/09/2009 by Pedro Padron – Be the first to comment

What I’ll describe here is the process of writing some custom facts to retrieve useful information from Parallels Plesk servers, so that you can use them in your Puppet recipes.

For those of you who don’t know what Facter is, I’ll quote the manufacturer’s description:

Reductive’s analysis tool for reporting system configuration and status, used to parametrize Puppet configurations

If you don’t know what Puppet is all about also, check it out right now or this article won’t make sense to you.

read more »

(Português) ProFTPd: o arquivo de scoreboard e informações sobre sessões ativas (ftpwho, ftptop e ftpcount)

Posted in sysadmin on 24/09/2009 by Pedro Padron – Be the first to comment

Sorry, this entry is only available in Português.