Archive

Archive for the ‘Linux’ Category

The Gods Must be Crazy

November 30th, 2008

hinepare

Okay, I know the Maori are from New Zealand and The Gods Must be Crazy was set in Africa, but I could not resist this fantastic oil of Hinepare.
ubuntu I don’t speak Maori, do you? I understand, and appreciate, that one of Ubuntu’s strengths is its embracement of and support for the international community. Hell, Linux as we know it today wouldn’t exist if it wasn’t for developers, maintainers and support people from all over the planet.

Language Packs

earth With that said, I have a a bit of an ax to grind with Canonical. After first booting up my brand new Ubuntu 8.04 LTS (Hardy Heron) desktop/development server and logging in and starting the Gnome desktop, the Update Manager indicated I should upgrade some software. I was of course expecting this. What I wasn’t expecting was 500+ pairs of language packs—some I’d never even heard of. There are a number of reasons this annoyed me. For one, other than my native English and perhaps some languages I’m at least familiar with (Spanish, French, German, etc.) there was no need to waste CPU or my time, god only knows how much disk space, and, worst of all, I knew that in certain applications if you selected a menu (the Firefox spell checker came to mind) you’d end up with and option list from here to Auckland. So I spent the better part of half an hour unchecking all these language pack updates and ran the updater on the rest. That seemed reasonable, if a tad bit tedious.

But oh no, the next day Update Manager was back with a vengeance, once again suggesting I install all these language packs. This time I relented, but waited until just before bed to run the damn thing. I know what you’re thinking, I’ll get to that in a moment.

screenshot

System -> Administration -> Language Support: My saving grace, or was it?

Language Support

flag Call me a n00b, but it wasn’t until after all of this and doing some research that I realized I could use the Language Support tool to disable all of these obscure (at least to me) languages. If you’re wondering why Maori is checked in the screenshot, well, a weak attempt at humor I suppose.

The Agony of the Desktop

foot Okay, now comes the really strange, and by far the most frustrating part. After all of this was said and done, at least in my mind, I wanted to move the new machine from its temporary digs to my office and add it to the network. This of course entailed shutting the server down, which I am loathe to do with any Unix-like machine. I would prefer the sucker to hum along nicely for a good long while barring any catastrophies like a power outage that lasts longer than a UPS. But it needed to be done, so move it I did. With everything ready to go, I booted it back up, got my Gnome login screen, and then nothing. Just a blank screen, save for the default butternut squash colored background. No menu panel, no Hardy Heron desktop background image, nothing. I sat there and stared at it, dumbfounded.

It Gets Stranger

Finally, after a bit a gray rectangle, that was obviously the beginnings of a window of some kind, appeared in the upper left corner of the screen. Only no window, just the metrics of one. I assumed this was X11 trying to tell me something, but what it was at first remained a mystery. So I tried C+A+B to restart the display manager—same thing. Then I tried C+A+F1, waited for a bit, then C+A+F7, and waited at the squash screen a little longer staring at the gray box. Finally, an error window appeared:

There was an error starting the GNOME Settings Daemon

toetag WTF? Even stranger, after I dismissed this error dialog my panel icons mysteriously had changed, but after a few minutes, poof! They changed back. So, naturally, it was time to fire-up Firefox and visit good old Uncle Google. After searching and reading I found the page I was looking for and it made perfect sense in hindsight. I, of course, had shot myself in the foot when I was configuring my network interfaces.

Solution

Always, always, make sure you have the loopback (lo) configured properly and you can ping yourself. In /etc/network/interfaces:

# loopback interface

auto lo
iface lo inet loopback

In /etc/hosts/:

127.0.0.1 localhost lo [hostname]

Where [hostname] makes you happy. Restart networking:

$ sudo /etc/init.d/networking restart

Ping yourself:

$ ping -c4 lo
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.030 ms
64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.027 ms
64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.027 ms
64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.028 ms

--- localhost ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 2997ms
rtt min/avg/max/mdev = 0.027/0.028/0.030/0.001 ms

Finally, restart the display manager aka Gnome desktop to make sure…problem solved. Phew!

Thanks Arun.

See Also

Linux , , , , , , , ,

Hardy Heron is Here

November 27th, 2008

heron

Finally, a default Ubuntu desktop background that doesn’t suck.
ubuntu The new Ubuntu desktop/development server just arrived (a week early I might add). I’ll be running Ubuntu 8.04 LTS (Hardy Heron) with a whole bunch of packages installed for local Web development. It’s about time I had a decent server.

LAMP

debian After the prerequisite setting of the root password, creating a group and login for myself, and installing a few dot files to get comfortable, it’s time to install the ubiquitous stack—with a number of goodies thrown in:

$ sudo apt-get install\
  apache2\
  apache2-dev\
  php5\
  php5-dev\
  mysql-server\
  mysql-client\   # for C/Perl client interfaces
  php5-mysql\
  php5-xdebug\
  php5-apc\
  php5-gd\
  php5-imagick

At this point, you might want to get yourself a coffee or something—that’s a lot of software to download, build and install. When complete, you will most likely need to make some changes to your config files: apache.conf, php.ini, my.cnf, etc.

package If any of these packages complain about missing dependencies, try:

$ sudo apt-get build-dep [package]
$ sudo apt-get install [package]

You should probably consider changing the Apache/MySQL user/group daemons, and set the MySQL root password. Once you’re good to go, start the server:

$ sudo /usr/local/apache2/bin/apachectl start

And visit http://localhost/

If everything went well, you’ll get a welcome screen. I usually drop a little PHP script into docroot (normally /var/www/) to review settings and such:

<?php phpinfo(); ?>

xdebug If you’re planning on using the Xdebug profiler, you might want to check into Cachegrind and the various alternatives for viewing the output.

MySQL Toolkit

maatkit Speaking of goodies, Maatkit (formally MySQL Toolkit) includes:

And a whole lot more.

$ sudo apt-get install maatkit

Editors

vim You can’t write code without an editor. My personal favorite:

$ sudo apt-get install vim-gnome

Tweak it any way you like. Some good places for tips:

zend If you prefer an IDE over the command-line, then I recommend Eclipse. NetBeans is another choice, however Eclipse shines with PDT installed. Eclipse requires a JRE, as does OpenOffice (OOo) for some features. If you are having problems with the one already on the box, try installing the Sun JRE:

$ sudo apt-get install sun-java6-bin

image

QGit screenshot, how sweet is that?

Version Control

git Only fools still write software without maintaining their code in version control repositories.

$ sudo apt-get install subversion libapache2-svn
$ sudo apt-get install git-core git-svn

Git fans should be interested in QGit.

Other Development Tools

bugzilla Depending on the complexity of your project(s), whether this server is being built for a single developer working on a brand new application, or perhaps it will be used for multiple projects, some already off the ground, with multiple developers, and so on, there are some other tools that are worth considering. Trac combines issue/bug tracking, a wiki, and an interface to Subversion. Bugzilla is another very popular alternative, and there are other choices.

mediawiki If you decide a bug tracker isn’t required at this juncture, don’t overlook the importance of documenting your work. There are all sorts of methods for doing this, but I’ve found that wikis are great tools, no matter what the size of the team.

python Like Perl, Python is another great tool that excels at all sorts of things besides Web development, and many of the other tools listed here rely on it. Hardy Heron comes preloaded with Python 2.5. If you want to upgrade to 2.6, it’s a little tricky since, as of this writing, no Debian package exists for it. Why, I’m not sure. But you can build it from source. This article will help.

Productivity Applications

  • OpenOffice — word processing, spreadsheets, presentations, draw…
  • Gimp — who needs Photoshop? Or the price tag.
  • Inscape — who needs Illustrator? Ditto.
  • Pidgin (formerly Gaim) or Empathy — IM/chat clients.
  • Thunderbird — email client.

firebug There should be no need to mention Firefox. Or the wealth of addons that make Web development so much more rewarding than in years past.

The Price is Right

The price of hardware has steadily fallen over the past few decades, while throughput and the quality of software have been inversely meteoric.

Server Hardware

  • Pentium dual-core processor E2200 (1MB L2, 2.2GHz, 800FSB).
  • 2GB dual channel DDR2 SDRAM at 800MHz.
  • Intel Graphics Media Accelerator 3100 (this isn’t for gaming).
  • 250GB Serial ATA hard drive (7200RPM) with DataBurst cache.
  • 16x DVD/RW drive.
  • 10/100 Ethernet.
  • 7.1 Channel audio.
  • USB Keyboard/Optical mouse.

Price: $250. You heard me, but that’s without a monitor. I have a 22” FS that will do just nicely, thank you.

Software

A downright embarrassment of riches. Which also contributes to the low cost of the hardware itself, since you aren’t paying all those commercial vendor licensing fees. I won’t name names. No I didn’t build the server myself—my hardware days are over.

Price: $free.

A special thanks and kudos goes out to the thousands of open-source developers, maintainers and supporters who work countless hours to bring us all this fantastic software. The Web, and our lives, wouldn’t be the same without them.

Life is good.

See Also

More of the above, as they roll in.

Apache, Linux, MySQL, PHP , , , , , , , ,

WordPress and Unix File Permissions

November 22nd, 2008

image

Learn from the Unix Masters! (okay, I’m not a wizard but I know a thing or two).
freebsd For most users, between WordPress themes and plugins, you want permissions on files and directories under your install directory set correctly in order to do nice things like edit your stylesheets (Theme Editor) and save settings (various plugins).

It’s important to keep in mind the ownership of these files and folders (normally you) is not the same as the ownership of the process (your Web server) that attempts these file create/open/read/write operations as a sort of agent on your behalf. Typically, the easiest thing to do is be liberal and set the read+write permissions for owner, group and others (everyone) on files and read+write+execute on directories.

Why execute on directories? I’m not going to get into a long tutorial here on Unix file permissions, but I will provide some helpful links at the bottom of the post.

Now let’s say you wanted to take care of this in one fell swoop so you need never worry about seeing a notice from WordPress, rather than dealing with it piecemeal as you run across the problem. To do this you’ll need shell access to your server and two useful Unix commands: find and chmod (change file modes). In fact, we’re going to use them in conjunction.

find+chmod

The basic layout of the find command is:
find [start] [flags]
Where:
  • [start] — the directory to start searching from.
  • [flags] — any number of options to control what happens next.
Under Unix, just as in DOS/Windows, there are two special directories ‘.’ and ‘..’ which correspond to the current directory and its parent. So if you change (cd) into the root of your WordPress install directory and issue the command:
www/wp> find .
 

it will recursively list every directory and every file on up. Which isn’t very useful in itself, there are easier and better ways to do that. What we want to do is filter the results, and apply a command on each. That’s where the find flags come in. A really handy one is -type [arg]. In our case we want to use two arguments ‘f’ (regular file) and ‘d’ (directory). Try the latter to see what happens:

www/wp> find . -type d
.
./img
./wp-includes
./wp-includes/js
./wp-includes/js/jquery
...
And the same (or rather opposite) is true if you use the ‘f’ argument. Now what we want to do is apply the chmod command on each and every file or directory. To do that we add a second flag to find, -exec, followed be some funny looking arguments. The first one is the command, chmod of course, followed by the mode argument, followed by the placeholder ‘{}’ that represents the results of the find command, followed by a terminating semicolon which tells find just that, stop, I’m done with this execute string. One thing to watch out for here is the fact that a semicolon (and other special characters) have special meaning to the shell itself, so you will either have to backslash escape them or use single quotes around groups of them. We’ll use both techniques.

File and Directory Modes

For files we want read+write on owner, group and others (rw-rw-rw- or octal 666), and for directories we want read+write+execute on the same set (rwxrwxrwx or octal 777). Armed with everything we’ve learned so far, put it all together in two commands:
www/wp> find . -type d -exec chmod 777 '{}' \;
www/wp> find . -type f -exec chmod 666 '{}' \;
And just like that, no more messages from WordPress about not being able to create or update files.

Nice, eh?

Security

However, this sort of approach has a downside—particularly if you’re on a shared host. If this is a concern, and it should be, you can learn a lot more about configuring WordPress at the database level, and file permissions, at How to Install WordPress Securely.

See Also

FreeBSD, Linux, WordPress , , , , ,