Tag Archive: ubuntu


If you’re not familiar with HAProxy, you’re missing out! HAProxy is a very intelligent high-availability reverse proxy that operates all the way up to Layer 7. Unlike Nginx (another good choice), HAProxy is not a webserver, it is designed with only high availability and load balancing in mind. Another great feature is that it’s a lot cheaper than your typical Layer 7 Load Balancer, free :).

There are plenty of good articles out there on HAProxy, but I couldn’t find any Debian/Ubuntu packages for the latest version (1.4.15). The Ubuntu 11.04 repo’s newest version is 1.4.8, but if you want some of the cool new features of 1.4.9-1.4.15, you have to build it from scratch. This process isn’t too painful, but I’ve got a lot of servers to put HAProxy on and I don’t want dpkg / apt-get to freak out and install the old HAProxy in order to satisfy a dependency.

For this reason, I’ve created an Ubuntu 11.04 x64 HAProxy package with TCP Splicing, Full Transparent Proxies and PCRE enabled:

HA-Proxy version 1.4.15 2011/04/08
Copyright 2000-2010 Willy Tarreau <w@1wt.eu>

Build options :
  TARGET  = linux26
  CPU     = native
  CC      = gcc
  CFLAGS  = -O2 -march=native -g -fno-strict-aliasing
  OPTIONS = USE_LINUX_SPLICE=1 USE_LINUX_TPROXY=1 USE_PCRE=1

Default settings :
  maxconn = 2000, bufsize = 16384, maxrewrite = 8192, maxpollevents = 200

Encrypted password support via crypt(3): yes

Available polling systems :
     sepoll : pref=400,  test result OK
      epoll : pref=300,  test result OK
       poll : pref=200,  test result OK
     select : pref=150,  test result OK
Total: 4 (4 usable), will use sepoll.

Feel free to grab haproxy_1.4.15_amd64.deb (502k SHA1: 8b2ecf05544e0f6531e50bf40261e0b112db61e9)
You can also grab the sources from here: http://www.stevekamerman.com/haproxy/

I recently created Tera-WURFL Explorer to allow people to browse through the WURFL, search for devices and upload images to the WURFL images collection. I originally used MySQL’s FULLTEXT index to let people search for devices, but quickly realized that it did not suit my needs. The main problem was that it does not index words smaller than what is specified in my.cnf (ft_min_word_len), and if you want to change it, you need to change it server-wide. This was not a good option for a large virtual host setup since it would affect all the FULLTEXT indices on the server; also, if you do change it, you need to reindex every FULLTEXT column in every database to prevent data corruption.

I did some research on search engines and eventually settled on Sphinx – mainly because it has a cool name, but also because there are some big-name success stories from companies like Craigslist who switched to it and never looked back.

Here’s how I installed it on Ubuntu 9.10:

First, you need to install the dependencies and download sphinx, then extract the archive and make it:

apt-get install g++ libmysql++-dev
cd /tmp
wget http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz
tar -zxvf sphinx-0.9.9.tar.gz
cd sphinx-0.9.9
./configure --prefix=/usr/local/sphinx
make
make install

Now all the sphinx-related files are in /usr/local/sphinx.
Next, I created a system user and group called “sphinx”:

adduser --system --group sphinx

Note: on RedHat-like systems, you can use “adduser -r -n sphinx”

Now, I created an init script for it. I would recommend downloading my init.d script.

wget http://www.tera-wurfl.com/blog_assets/searchd
mv searchd /etc/init.d/
chown root:root /etc/init.d/searchd
chmod 755 /etc/init.d/searchd

This script adds the following functionality:

# Start the Sphinx service
service searchd start
# Stop Sphinx
service searchd stop
# Check if Sphinx is running
service searchd status
# Reindex every Sphinx index (works while started or stopped)
service searchd reindex

Now we’ll add sphinx to the startup and use the config option to setup sphinx to run as the sphinx user:

update-rc.d searchd defaults
service searchd config

Note: on RedHat-like systems you can use “chkconfig –add searchd”

Lastly, you need to configure sphinx. I would copy the default config file and edit that one:

cp /usr/local/sphinx/sphinx.conf.dist /usr/local/sphinx/sphinx.conf

You can follow along with the comments in the file, or jump on the documentation site and figure out what all the settings do.

Now everything is setup and should work properly!
If you followed my directions and put the tarball in /tmp, the sphinx PHP and Python APIs and some examples are in /tmp/sphinx-0.9.9/api/. You should put a copy of the PHP or Python API somewhere else on the system so you can use it from your applications.

To see my use of the Sphinx search engine, take a look at this site:
http://www.tera-wurfl.com/explore/browse/

I recently installed ubuntu 7.10 (feisty fawn) on my Compaq R3000. Since this laptop has an AMD Athlon 64 (3500+), I decided to use the AMD64 version of ubuntu. I was able to get it installed and running well without much fussing. There were 3 main things I wanted to accomplish that did not immediately work:

Install Flash Player 9
Install NVidia Drivers and use GLX Desktop Effects
Configure and use the internal wireless card

I was able to get Flash Player 9 working with nspluginwrapper – this package allows you to install 32-bit Mozilla plugins on a 64-bit version of FireFox.

I got the wireless card working with the bcm43xx package.

I might write more detailed instructions on getting the last two things working later, but I just got the NVidia 64-bit drivers working today so I will go into more detail about them.

Installing the 64-bit NVidia drivers
I read about this great NVidia installation script called Envy in Linux Journal today.
Go to http://albertomilone.com/nvidia_scripts1.html and download the deb file (currently envy_0.9.7-0ubuntu8_all.deb).
Run the file to install Envy.

After Envy is installed, run it from your GUI by going to a terminal and typing “sudo envy -g” (-g == graphical)

The installer will download 60+ packages and install them for you, including the NVidia driver for your computer/configuration.

When it is done you will need to restart your computer.

Enabling Desktop Effects
When it comes back up you should be able to enable the desktop effects by going to “System”=>”Preferences”=>”Desktop Effects” and enabling the options you want.

If you have the same bad luck that I did, you will notice that the desktop effects will have made your title bar and other window decorations disappear. Although I’m not sure what causes this problem, here’s how I fixed it:

sudo nano /etc/X11/xorg.conf

Find the “Device” section and add:

Option "AddARGBVisuals" "True"
Option "AddARGBGLXVisuals" "True"
Option "NoLogo" "True"

Find the “Screen” section and make sure the default depth is 24:

DefaultDepth    24

Now restart your computer and you should be good to go!

My /etc/X11/xorg.conf for reference

# /etc/X11/xorg.conf (xorg X Window System server configuration file)
#
# This file was generated by dexconf, the Debian X Configuration tool, using
# values from the debconf database.
#
# Edit this file with caution, and see the xorg.conf(5) manual page.
# (Type "man xorg.conf" at the shell prompt.)
#
# This file is automatically updated on xserver-xorg package upgrades *only*
# if it has not been modified since the last upgrade of the xserver-xorg
# package.
#
# If you have edited this file but would like it to be automatically updated
# again, run the following command:
#   sudo dpkg-reconfigure -phigh xserver-xorg

Section "ServerLayout"
Identifier     "Default Layout"
Screen         "Default Screen" 0 0
InputDevice    "Generic Keyboard"
InputDevice    "Configured Mouse"
InputDevice    "stylus" "SendCoreEvents"
InputDevice    "cursor" "SendCoreEvents"
InputDevice    "eraser" "SendCoreEvents"
InputDevice    "Synaptics Touchpad"
EndSection

Section "Files"

# path to defoma fonts
FontPath        "/usr/share/fonts/X11/misc"
FontPath        "/usr/share/fonts/X11/cyrillic"
FontPath        "/usr/share/fonts/X11/100dpi/:unscaled"
FontPath        "/usr/share/fonts/X11/75dpi/:unscaled"
FontPath        "/usr/share/fonts/X11/Type1"
FontPath        "/usr/share/fonts/X11/100dpi"
FontPath        "/usr/share/fonts/X11/75dpi"
FontPath        "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
EndSection

Section "Module"
Load           "i2c"
Load           "bitmap"
Load           "ddc"
Load           "extmod"
Load           "freetype"
Load           "glx"
Load           "int10"
Load           "vbe"
EndSection

Section "InputDevice"
Identifier     "Generic Keyboard"
Driver         "kbd"
Option         "CoreKeyboard"
Option         "XkbRules" "xorg"
Option         "XkbModel" "pc105"
Option         "XkbLayout" "us"
EndSection

Section "InputDevice"
Identifier     "Configured Mouse"
Driver         "mouse"
Option         "CorePointer"
Option         "Device" "/dev/input/mice"
Option         "Protocol" "ExplorerPS/2"
Option         "ZAxisMapping" "4 5"
Option         "Emulate3Buttons" "true"
Option         "Buttons" "7"
Option         "ButtonMapping" "1 2 3 6 7"
EndSection

Section "InputDevice"
Identifier     "Synaptics Touchpad"
Driver         "synaptics"
Option         "SendCoreEvents" "true"
Option         "Device" "/dev/psaux"
Option         "Protocol" "auto-dev"
Option         "HorizScrollDelta" "0"
EndSection

Section "InputDevice"
Identifier     "stylus"
Driver         "wacom"
Option         "Device" "/dev/input/wacom"
Option         "Type" "stylus"
Option         "ForceDevice" "ISDV4"        # Tablet PC ONLY
EndSection

Section "InputDevice"
Identifier     "eraser"
Driver         "wacom"
Option         "Device" "/dev/input/wacom"
Option         "Type" "eraser"
Option         "ForceDevice" "ISDV4"        # Tablet PC ONLY
EndSection

Section "InputDevice"
Identifier     "cursor"
Driver         "wacom"
Option         "Device" "/dev/input/wacom"
Option         "Type" "cursor"
Option         "ForceDevice" "ISDV4"        # Tablet PC ONLY
EndSection

Section "Monitor"
Identifier     "Generic Monitor"
HorizSync       28.0 - 64.0
VertRefresh     43.0 - 60.0
Option         "DPMS"
EndSection

Section "Device"
Identifier     "nVidia Corporation NV17 [GeForce4 420 Go 32M]"
Driver         "nvidia"
Option "AddARGBVisuals" "True"
Option "AddARGBGLXVisuals" "True"
Option "NoLogo" "True"
EndSection

Section "Screen"
Identifier     "Default Screen"
Device         "nVidia Corporation NV17 [GeForce4 420 Go 32M]"
Monitor        "Generic Monitor"
DefaultDepth    24
SubSection     "Display"
Depth       1
Modes      "1280x800"
EndSubSection
SubSection     "Display"
Depth       4
Modes      "1280x800"
EndSubSection
SubSection     "Display"
Depth       8
Modes      "1280x800"
EndSubSection
SubSection     "Display"
Depth       15
Modes      "1280x800"
EndSubSection
SubSection     "Display"
Depth       16
Modes      "1280x800"
EndSubSection
SubSection     "Display"
Depth       24
Modes      "1280x800"
EndSubSection
EndSection

Section "Extensions"
Option         "Composite" "Enable"
EndSection