No More XAMPP For Me! A Better Alternative Exists On Xubuntu

If you’re on a Ubuntu-based distro, you’re in luck: you don’t have to install XAMPP to get a web server started! Just install the following packages, including all dependencies, in order:

  1. mysql-server
  2. apache2
  3. php5

Restart Apache with sudo /etc/init.d/apache2 restart. (Apache should complain like this: “Could not determine the server’s fully qualified domain name, using for ServerName” — to resolve this, open up /etc/apache2/httpd.conf and add a line like ServerName localhost. See this page for more info.)

Optionally, install phpmyadmin.

For phpmyadmin, the administrative user is “root”, as usual.

Your web pages are now stored in the /var/www/ directory. From here, symlink to any other directory in your hard drive to include that directory into your web server! The beauty of this method, instead of going with XAMPP, is that your system will automatically update all web-server related components whenever you update your system with apt-get or Synaptic Package Manager or whatever. Also, Apache will start automatically whenever you reboot. No more downloading XAMPP and extracting as superuser, and repeating it all over again every time XAMPP updates to a newer version. No more firing up a terminal and telling XAMPP to start with that horrendously long command sudo /opt/lampp/lampp start. Hooray Ubuntu!

The above steps worked fine for me on Xubuntu 8.04.1.

UPDATE March 23, 2009: I’m on Arch Linux now, and I simply followed the Arch wiki on Apache et al to get things rolling without XAMPP. And it works just fine. Use Arch!

Changing Boot Priority in an Ubuntu Derivative

Apparently, the most popular search term for this blog in the past 30 days is: “changing boot priority linux mint”. So I will post what I know.

Now, “changing the boot priority” is ambiguous; it could mean simply changing which OS is selected by GRUB by default. Or, it could mean that Linux Mint (or Ubuntu, Xubuntu, Kubuntu, or whatever else derivative) cannot boot from the current hard drive (that GRUB’s understanding of the hard drives is messed up). For this second scenario, have a look at my other post on a very similar issue.

So the solution to the first meaning (changing which OS is selected by GRUB by default) is as follows:

  1. Open up /boot/grub/menu.lst with super user privileges. E.g., “gksudo gedit /boot/grub/menu.lst“, if you like gedit. Replace gedit with your favorite text editor, like mousepad for instance, if you have it.
  2. Go to the line that says default          0. This is should be the 14th line down, on Xubuntu 8.04.1.
  3. Change the 0 to 1 for the second option, 2 for the third option, 3 for the fourth option, and so on, as shown in your GRUB menu screen.
  4. Save and reboot!

So, for example, the relevant portion of my menu.lst looks like this:

title        xubuntu 8.04.1, kernel 2.6.24-19-generic
root        (hd0,6)
kernel        /boot/vmlinuz-2.6.24-19-generic root=UUID=70674f56-b99e-42f4-af6d-c760abe21ec4 ro quiet splash
initrd        /boot/initrd.img-2.6.24-19-generic

title        xubuntu 8.04.1, kernel 2.6.24-19-generic (recovery mode)
root        (hd0,6)
kernel        /boot/vmlinuz-2.6.24-19-generic root=UUID=70674f56-b99e-42f4-af6d-c760abe21ec4 ro single
initrd        /boot/initrd.img-2.6.24-19-generic

title        xubuntu 8.04.1, memtest86+
root        (hd0,6)
kernel        /boot/memtest86+.bin


# This is a divider, added to separate the menu items below from the Debian
# ones.
title        Other operating systems:

# This entry automatically added by the Debian installer for a non-linux OS
# on /dev/sdb1
title        Microsoft Windows XP Professional
root        (hd1,0)
map        (hd0) (hd1)
map        (hd1) (hd0)
chainloader    +1

So here, my default      x option would be as follows:

  • 0 = Xubuntu
  • 1 = Xubuntu (recovery mode)
  • 2 = memtest86+
  • 3 = “Other operating systems:”
  • 4 = Microsoft Windows XP

I’ve never tried using option “3” for my computer. I think it would probably just repeat GRUB’s menu if on a timer and it ends up selecting option “3”.

Welcome to the Linux community!

Poor Man’s Debugging in C++

Disclaimer: I suspect that this post won’t be useful to anyone who really knows how to debug a program — but hey, the procedure I describe is so simple, and has no learning curve!

I am a novice C++ programmer. Recently, I’ve been using a simple trick to see which portions of my code are being accessed or not. Simply include the cassert header in your code, like so:

#include <cassert>

Now, include the statement assert(0); in the part of your code that you suspect is causing your program to crash. The assert() macro aborts your program if the condition given is zero or false — so if we hard-code a failing argument, as in assert(0), your program will terminate consistently, upon executing that particular assert(0) statement.

The cool part: if your code executes the assert(0) statement, then that means that, up to that point in your code, your program worked perfectly fine. On the other hand, if you cannot get your program to abort with assert(0), this means that your program hangs or crashes before getting to the “assert(0)” statement ; thus, you can just move this “assert(0)” statement up (“up” as in an earlier point of time in the manner your code is executed), and repeat the procedure above to get closer to the bug.

So, for example, if you have a FOR loop, and inside this FOR loop, the first thing you put in is assert(0), and nothing happens, this means that the FOR loop isn’t even being executed at all! Similarly, simply put in assert(0) inside a function, to see whether that function is being called; if it IS being called, your program will abort with assert(0).

As a general practice, you could put in many assert() statements in your control flow code, so that they only execute if the statement inside assert() is true.

Xubuntu + Dell Latitude D505 Tips

A couple quick tips for some nagging problems, and fixes, I encountered on my old Dell Latitude D505 laptop after a fresh Xubuntu 8.04.1 install:

  • You might experience a “pop!” sort of sound (NOT a system beep) every few seconds, or minutes. You might also have discovered that the screen slightly goes dark sometimes after each “poppping” noise. This is most likely due to a shoddy AC Power adapter hooked up to your laptop. It was the case for me — so much for power adapters from eBay. Anyway, the reason why Xubuntu is playing this “pop” sound (which you notice is simply a sound file, since you can kill it if you mute the sound) is because it considers the unplugging of your AC Power cord as an “error”, and plays this sound, which represents a generic system “error.” So to disable the sound, you need to disable the sound: click on Menu -> Settings -> Settings Manager -> Screensaver -> Power Management, and from here, go to the General Tab and uncheck the Use sound to notify in the event of an error checkbox. Tada! And, to disable the screen from flickering each time, go to the On Battery Power tab, and uncheck the Reduce backlight brightness option. Problem fixed! (Or of course, just get a good AC Power adapter.) Credits.
  • The touchpad “tap” or “tapping” feature to click on a button or item is too sensitive for me by Xubuntu’s default settings. Unfortunately, there is no way you can disable this setting, unless you manually edit the usual /etc/X11/xorg.conf file. Just follow CJ56‘s instructions as stated here on post #5. In case the forum is down, here is what he said: add the lines Option “MaxTapTime” “0”” and also Option “MaxTapMove” “0” under your “InputDevice for your “SynapticsTouchpad” value. Now, your touchpad’s tapping functionality is gone. Of course, you can comment out those lines or delete them if you want tapping back.

Some More Reflections on Linux (Xubuntu 8.04.1)

I couldn’t resist any longer. After a few months of using Elyssa (Main Edition) on my old Dell Latitude D505 laptop, I could not bear the system hog duo that is the GNOME desktop environment + compiz-fusion. Yes, I could have removed compiz-fusion, and that by itself would have probably speeded my aging laptop significantly — but why slice one head when you can slay the hydra?

So I installed Xubuntu 8.04.1 32-bit yesterday on my laptop. This is, oh dear, my 6th Linux installation, if I’m counting correctly! So everything went really really fast. I love XFCE. The speed, and the simplicity, is beautiful. Well, I’ll be honest: I first welcomed GNOME’s user-friendliness combined with Elyssa’s own user-friendly customizations on top of the Ubuntu base, like how Elyssa grouped together all the administrative programs (the “Control Center” equivalent programs) neatly in its Panel’s Menu and all. But after reading tens, if not over a hundred, tips on how to fix things or customize this-or-that using the trusty terminal, and also learning that GNOME’s “look and feel” has nothing to do with GNOME, but rather, the GIMP Toolkit, more commonly known as “GTK+”, I realized that I had zero reasons to choose Elyssa over Xubuntu. Xubuntu is not well known, I don’t think, but do realize that it also uses the GTK+ GUI toolkit — this means that, yes, you can install fancy shmancy things like the Aurora GTK+ Engine if you want on Xubuntu (although, because of a tiny bug in right-clicking menus when using Thunar, I’ve decided to go with a similar, Aurora theme derivative on my desktop machine).

Here are some other “realizations” that dawned upon me after prolonged Linux usage:

  • Do not trust your Panel’s “Menu” or “Start” button. You have numerous applications already installed (usually in /usr/bin) that may not show up in that menu, and you can start any of them by simply typing in their executable’s name in your terminal. Case in point: Linus Torvald’s fashionably high-tech git source management program after you install it with apt-get. This is because the “/usr/bin” directory is in your PATH environment variable. (Open up the /etc/environment file if you’re curious.)
  • Ninety-nine percent of everything is customizable in Linux. To me, this means that you shouldn’t depend on your distro to set up all the bells and whistles for you. It’s much more rewarding if you do it on your own. A good example is customizing, say, conky.
  • Packages (one or more components that make a program work) are designed around a good software philosophy, in that generally you won’t find one giant package that is the only thing you’ll ever need for a particular program. Usually, if you install a new program with get-apt or Synaptic, it will notify you of 3, 4, or more so-called “dependencies” that are required to get that program to run. This is a good thing, because this means that, generally, a single package is specialized, and modularized, to do few things well. This also means many people are involved to get one thing to work if there are many dependancies involved. The end result is that, if any “core” or very basic dependency that many programs use gets a bug, it will be notified immediately and fixed. I doubt it even gets to this stage for some of  those really important packages, like gcc. But ultimately, this all boils down to one thing: software reliability.
  • Aesthetically, compiz-fusion and things like KDE4 are visually impressive, but in the end, only just that: visually impressive. They ultimately slow your system down unnecessarily, and introduce more variables to your X window system (Yes, for you Linux total newbies out there: Ubuntu, Xubuntu, Linux Mint — all of these distros use the X window system, on top of which they use GTK or QT or whatever else GUI they happen to prefer). I have to admit, I really liked using compiz-fusion with the desktop cube plugin the first month or so — but then I realized that using the cube with compiz-fusion actually slowed down my productivity. To compare: in Xubuntu, by default, all you have to do is scroll your mouse wheel down one notch (when hovering over the desktop) for the next workspace. And it happens almost instantly. Unless you want to watch your favorite DVD movie mirrored horizontally, I just don’t see the benefit of compiz-fusion and all that.
  • Lastly, your Linux customizations really depend on what you like to do and want to do on your computer. Don’t get carried away at what other users are boasting about on forums about their latest trick or customization. Fit Linux to serve your needs. Take what you need, and discard everything that you don’t need. Thankfully, FOSS lets you do this painlessly, since, nothing is impossible — all the source code is there, and you can do whatever you want with it!!

So anyway, both my desktop and laptop are using Xubuntu now (64-bit version on the desktop and 32-bit version on my laptop), and my Elyssa usage is pretty much dead. Still, I’d like to thank Linux Mint for letting me first get my feet wet in the wonderful world of Linux computing. I’m somewhat of a reasonably competent Linux user now, especially with all those helpful forum posts readily accessible on Google.

So yeah, I’m a Xubuntu user now. Hooray.