June 25th, 2008 — Linux, PHP
I’ve installed rubygems manually (no package manager) in my home directory. But since then “gem –version” reported that it could not it’s version. So now I’ve removed the previous installed version, downloaded the tar and reinstalled. I’ve used this command to install this time:
ruby setup.rb --destdir=~/.rubygems --prefix=/
And now it runs fine!
leon@polly:~$ gem1.8 --version
1.2.0
And I’ve installed ruby 1.8.7 (from Intrepid) on Ubuntu Hardy. But more on that in my next post.
June 20th, 2008 — development, Linux, Ruby
I’ve installed puppet recently and I’m know trying to understand how it works and make use of it
If that’s not difficult enough, I encountered this weird behaviour that the –noop argument didn’t do anything. After an hour of searching I realized it was my own stupid fault!
I had to puppet configuration files: /etc/puppet/puppetd.conf (old way) and /etc/puppet/puppet.conf (new way). I browsed throught the source code and it looks like puppet first checks the old file, if it is found it parses that one. If it’s not found, the new file is parsed. I don’t know why, but if the old file is used, the –noop argument isn’t parsed by puppet. So removing /etc/puppet/puppetd.conf was all I had to do. Pffff….
But why did I create the puppetd.conf file? Because I’v read the “Pulling strings with puppet”-book. And althought it’s fairly new, puppet is advancing at a very high rate. So the book is becoming out-of-date already.
June 16th, 2008 — Linux
I really like ubuntu and I wouldn’t try anything else if it wasn’t for Xen. I was trying to install Xen + xenman/virt-manager of Ubuntu Hardy. But xenman doesn’t install (the pulled it out of the repositories) and virt-manager gives all kind of python errors. Thank you ubuntu! Very nice with a long term release. And nobody’s even answered my bugreport about this issue.
So I decided to give Fedora a try. They’re the real driving force behind libvirt and Xen (Ubuntu picks kvm over Xen). So that must work?!
Because the pc I do all my testing on doesn’t have a cdrom drive I need to do a netboot (pxe) and install the desired distribution via a remote install. Ubuntu/debian has very nice images for this to do. Fedora takes a little more work to set this up. But their installer has a lot more options than the ubuntu/debian netboot. For instance, it’s possible to start a headless vnc install with Fedora. So when the netboot image has booted, you can connect to it with a remote client via vnc. Really nice! Especially if it’s a server where you don’t want to connect a monitor to it.
So how did I set up the tftp layout for Fedora? I used the two resources for documentation:
So after setting up the directory structure and downloading the initrd.img & vmlinuz, it was time to boot into the pxe image of fedora. This is the pxelinux.cfg/default by the way:
default install
LABEL install
kernel i386/vmlinuz
append initrd=i386/initrd.img vnc ip=dhcp ksdevice=eth0 method=http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Fedora/i386/os/ lang=en_US keymap=us
After the boot I have to skip one screen which asks if it should use ipv4 and/or ipv6. It’s really annoying, but I couldn’t find a way to disable.
Why is it annoying? Because you have to hook up a keyboard + monitor for it to confirm the question. When you’ve confirmed the question it boots up the installer in which you can login with vnc. So you don’t need a keyboard anymore at that point. The vnc server port is 5901! Not the standard 5900!
The Fedora installer really looks nice and Fedora itself has some nice things and some less nicer things. But more on that in my next post about Fedora 9.
June 14th, 2008 — development, Linux, PHP
At Tim_online we have several webservers and each of them have apache2 installed running php with fcgid (a fastcgi implementation). Why this configuration and not mod_php? Because it is reasonably fast (at leaster faster than plain cgi) an secure (because it doesn’t run under the apache user).
For it to run php scripts as the website owner, you need suexec.
Suexec is a mechanism supplied with Apache that allows to execute CGI scripts as the user they belong to, rather than Apache’s wwwrun user. This improves security in situations where multiple mutually distrusting users have the possibility to put CGI content on the server.
So when u visitor requests one of the webpages of one of my customers the proces looks like this:
request -> apache -> fastcgi -> suexec -> proxy -> php file
I don’t exactly know anymore why the proxy is required, but it is
Know the problem is: suexec (by default) can’t execute the proxy file, because it isn’t owned by the php file owner. So you have to hack suexec to make this work.
I did this. And everything worked. The webservers were happy to serve al these requests untill one day apache get updated. The automatic ubuntu updates push a new version of apache with a new suexec binary. Problem!
So when you come at work there are 16 “missed incoming calls” and you co-workers are going mad with all the dissapointed customers. You look at the apache logs: hmzzz, suexec is giving 120 errors… What could that be? !Ping! Suexec ofcourse. Let’s see, how did I solve this problem the last time. First let’s download the apache sources. ./configure. Yes. now where’s suexec.c? Ah, cd support. Now, make suexec. Wait, missing headers. Let’s install those first. Make suexec. Arrgh. It doesn’t work! Suexec -v. Wait, forgot to adjust the ap_httpd_user, ow, and comment out the offending lines. Yes, this should work. Ok. Copy it to /usr/lib/apache2. Ok, it works!
But at that time, an hour has past. If you can find the right files at once. So I decided to write down the steps I took to download, configure and compile suexec the quickest and simplest way. Here we go:
sudo apt-get install apache2-threaded-dev
mkdir -p ~/src/suexec
cd ~/src/suexec
sudo apt-get install apache2-threaded-dev
wget http://svn.apache.org/repos/asf/httpd/httpd/trunk/support/suexec.c
wget http://svn.apache.org/repos/asf/httpd/httpd/trunk/support/suexec.h
wget http://www.vanutsteen.nl/wp-content/uploads/2008/06/suexecc.patch
patch suexec.c suexec.c.patch -o suexec.patched.c
gcc -DLOG_EXEC='"/var/log/apache2/suexec.log"' -DAP_HTTPD_USER='"www-data"' -DAP_DOC_ROOT='"/var/www"' -I/usr/include/apr-1.0 -I/usr/include/apache2 -o suexec suexec.patched.c
That’s it! Test it by doing: sudo ./suexec -V
That should output:
-D AP_DOC_ROOT="/var/www"
-D AP_GID_MIN=100
-D AP_HTTPD_USER="www-data"
-D AP_LOG_EXEC="/var/log/apache2/suexec.log"
-D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
-D AP_UID_MIN=100
-D AP_USERDIR_SUFFIX="public_html"
Basically what I did:
- I installed the necessary headers
- Got the latests suexec code from the apache svn repo
- Downloaded the suexec patch from my blog
- Patched suexec to disable the file owner check
- Compiled suexec with the default ubuntu options
June 14th, 2008 — Other
A.K.A.: I bought a Logitech Harmony 525 remote control and a €1.49 remote saved my day!
When I say “525″ in this post, I of course mean the Logitech Harmony 525.
My boss gave me a Mediamarkt gift coupon and this week I decided to buy something for it. I chose a universal remote control, because my current tv (also from my boss ) had no remote control. I believe his daughter bit it to pieces :p
Logitech seemed a wise choice. I think it’s a trustworthy brand, and I really like their squeezebox line.
I plugged it in and of course linux doesn’t have any descent support for it
But Virtualbox to the rescue. I had already have it installed, so I fired it up, but the logitech remote didn’t show up in Windows. Hmzz, after reading the virtualbox FAQ I added this line to my /etc/fstab:
none /proc/bus/usb usbfs devgid=46,devmode=664 0 0
Restarted my box, fired up Virtualbox and voila: I could now access the remote from Windows XP. After installing the driver and signing up for an account I was of. Added my xbox, dvd player an tv to the remote and it worked! Not like a charm, because not all of the features of the original remote of my tv (a Sanyo CE28FWH2F-C) were added to the 525. A search on google didn’t return anything useful so the only solution was to copy the infrared codes from the original remote. But I didn’t have it so I took my chances with a cheap 1,49 remote from Action. And because of the nice Harmony remote software it was easy as pie.
June 9th, 2008 — Linux
I wanted to update my hardy servers automatically, so I could spend a little less time each week working on my servers. I’ve searched through the ubuntu wiki/documentation and I think using the unattended-upgrade package is the nicest alternative.
I installed two packages:
apt-get install unattended-upgrades update-notifier-common
And then edited two files:
/etc/apt/apt.conf.d/50unattended-upgrades
// Automaticall upgrade packages from these (origin, archive) pairs
Unattended-Upgrade::Allowed-Origins {
"Ubuntu hardy-security";
"Ubuntu hardy-updates";
};
/etc/apt/apt.conf.d/10periodic
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "1";
APT::Periodic::Unattended-Upgrade "1";
Now every day the server gets upgraded via /etc/cron.daily/apt
May 28th, 2008 — Linux
A little while ago I wrote a post about the wonderful guessnet. It really works well! It integrates so nicely with GNU/Linux that I wonder why (for example) the gnome network manager doesn’t make use of it! I’ve been playing with the thought of making a GUI for it. But for that I have to become a little better at making them
But back to why I’m writing this post: I had a problem with guessnet. I had a last-ressort profile for my wireless adapter. Whenever it can’t find a known network it looks for any open networks and tries to connect with that. But this rule didn’t work too well. It regulary got picked over any known closed network in my configuration file. So I contacted to creators of guessnet (Thomas and Enrico) and they reckoned it as a bug. After some mails they fixed it in the svn version of guessnet. So I set of to install it. I know a little of how debian packages are created so I couldn’t be too much of a hassle.
The steps I took:
sudo apt-get build-dep guessnet
mkdir -p ~/src/guessnet/trunk
svn co svn://svn.debian.org/guessnet/trunk ~/src/guessnet/trunk
cd ~/src/guessnet/trunk
./autogen.sh && fakeroot debian/rules binary
Et voila: a package was born. And it worked like a charm! Guessnet worked better than ever.
And when I did another svn update, I saw a .gitignore file appearing. So I believe they are considering git also. Go git!
May 24th, 2008 — development, PHP, Uncategorized
I the release post of com_resized there was asked the question why one should use com_resize. There are three reasons to use it:
- The generated images aren the size you want them to be. So they’re smaller of size than the original images.
- You won’t get any ugly resized images (see the example below).
- It works with remote images. So you can link to an image one someone else’s blog and they get resized to the size you want + cached. So that way they get loaded from your own server: so faster.
No more ugly resized images:
The one on the left is without com_resize. The one on the right is _with_ com_resize. If you don’t see any difference. Your browser is probably doing some fancy stuff with the image. In that case you don’t need com_resize. But maybe the readers of your blog do!
For the people who don’t see any difference (leave a comment with your OS + browser, please!) I have attached a screenshot. Made in IE6, so the font is ugly too
May 20th, 2008 — development, Ruby
Hi all! I’ve released my first project on rubyforge. The sourcecode is on github though. For the simple reason that my git repository on rubyforge doesn’t work (yet). I hope they will fix it soon.
I’ve setup the project with the wonderful bones of Tim Pease.
I’ve got some reasonable documentation about it, a kick-ass website (stolen from Dr. Nic’s newgem) and some nice unit tests. I’m now integrating the gem in one of my own projects. If that’s succesfull I’m gonna release a version 0.1. The version after 0.1 will have new features.
The website ws generated with webby. A really nice way to create static websites in ruby. Maybe I’ll dedicate a post/tutorial to webby.
So please look at the website, install the gem and give me some feedback. It will be very appreciated!
May 19th, 2008 — Other, Uncategorized
I always forget what tire pressure my Bridgestone battlax BT45′s have. So now to never forget:
2.5 & 2.8
(front & rear)