Tag Archive for 'Unix / Linux / *BSD software'

Goodbye, Apache; hello, lighttpd!

Fed up with how Apache memory usage grows (and grows, and grows), I’ve changed all of my sites on my external server (where, for instance, this very blog is hosted) to lighttpd, a.k.a. Lighty.

I began by changing the most problematic site to Lighty (listening on port 81), and using Apache’s proxy module to redirect it there. After the results were promising, I went and changed each site at a time, dealing with the particular problems of each (I use lots of redirects, and the syntax is a bit different, and, furthermore, Lighty doesn’t support .htaccess files.

WordPress was relatively easy (just one line). MyBB would have been even easier (nothing to do), if not for the fact that I use an SEO mod which uses an .htaccess file for nicer URLs. But everything was easier than I expected.

After each site had been “moved”, it was just a matter of stopping Apache and moving Lighty to port 80.

Memory usage is way down, and so is swap file usage (basically, it’s not being used, and it was, before — a lot). Barring any future problems, I’m quite happy with this set-up, and would advise this change to anyone who’s never tried anything other than Apache on an Unix system. I’ll probably try doing the same thing on my home server, too.

More additions to the PA top Technorati ranks table

The top technorati ranks table for Planet Atheism members has been improved again. :) In addition to showing the Technorati rank, number of incoming links (from Technorati as well), and Google Pagerank, the table now shows Alexa ranks as well.

You can now also click on any of the above column titles to sort the table by that particular value/rank. Incoming links and Pagerank are “the more, the merrier”, while Technorati rank and Alexa rank are “the lower, the better”, so sorting takes that into account.

A note of warning: I’ve mentioned before that you shouldn’t really take any of these ranks too seriously, and this is especially true for the Alexa ranks. Alexa is a nice idea (it’s the only one that measures traffic instead of incoming links), but it has the following problems:

  • it only counts hits if the user has installed either the Alexa toolbar (for Internet Explorer) or the SearchStatus Firefox extension (I recommend the latter, since, as everyone knows, MSIE sucks), and
  • it often lumps all subdomains for a particular domain together (i.e. doesn’t distinguish between aaa.domain.com and bbb.domain.com, even though they may be totally unrelated). It apparently has some hard coded exceptions for some (not all) blogspot.com blogs… but the values aren’t really reliable. Still, you can use it to measure the changes in traffic for one site.

Incidentally, the application I’ve coded (and have been improving) to generate this table from a list of blogs is almost ready for public release. :)

My Technorati ranks "toy"

Inspired by Carlos Andrade’s own tool, I’ve just coded a couple of scripts to take an OPML file and show an ordered table of Technorati ranks. Naturally, I used it for my own Planet site, Planet Atheism.

Here it is: Technorati Ranks for Planet Atheism members

The implementation was ridiculously simple (and there’s a lot of room for improvement), but, other than Carlos’ tool, I didn’t find any scripts or utilities to do this. And, yes, I searched. Therefore I may release the code soon, as the 2nd project on software.dehumanizer.com, since this can be a fun “toy”. :)

[EDIT: added each blog's Google PageRank to the table. Why not? :) ]

Using 64-bit Firefox on Linux

Since the dawn of 64-bit Linux distros, they have included 32-bit versions of browsers such as Firefox, because there aren’t 64-bit versions of plugins such as Java (the 64-bit version doesn’t have a plugin) or Flash.

A couple of days ago, however, I was reading the “what’s new” list for Suse 10.3 Alpha 3, and found this entry:

On x86-64: Firefox is now a 64-bit package and uses nspluginwrapper to handle 32-bit i386 plugins if needed.

Naturally, I had to investigate. I downloaded a 64-bit build of Firefox from Autofox, and nspluginwrapper. With that wrapper, I can use Flash without any problems. (Not Java, though; I think Blackdown offers a 64-bit plugin, but it’s Java 1.4.2 only. But I have found out that I don’t miss Java in the browser at all, for the past few days.)

The browser feels faster. I tend to use bookmark folders to open dozens of bookmarks at the same time on different tabs, which actually makes the browser “hang” for a couple of seconds, and those delays seem shorter now. No, I didn’t do any benchmarks. But the overall experience just “feels” better. It even appears to be more stable, though that may actually come from the fact that I’m using a 2.0.0.4pre build, which is the latest version (2.0.0.3) plus bugfixes… or maybe it’s because this version was built with a non-ancient, and possibly less buggy compiler.

Announcing DailyTasks 0.1

A few minutes ago, I submitted my first piece of software to Freshmeat (it hasn’t been approved yet; it will probably take a few hours): DailyTasks. It’s a small utility, written in PHP, with both a command line mode and a web interface, which, surprisingly enough, reminds you of daily tasks. :)

The web page linked above tells the “story” in more detail, but, basically, I’m much too chaotic to use traditional task management programs (every time I tried, I seemed to spend more time updating tasks than actually doing them), but I wanted something to remind me, every day, of doing something — from “clean up GMail’s spam folder” through “update a blog” to “do the laundry, if necessary”. :) There was already a similar program (frequent-task-reminder), but it lacked some features that I wanted (such as non-accumulating tasks), and so I wrote my own.

It’s really basic stuff, with no bells and whistles, and the PHP code would probably scare you, so impressionable young people should avoid looking at it. :) But maybe — just maybe — you’ll find it useful.

More about tidying up HTML

If you’re curious about the last post

I accept that making some HTML code validate in validator.w3.org shouldn’t be the be all, end all of the problem. A piece of code can validate and yet be… horrible. On the other hand, a piece of code may not validate because of a minor problem, and yet be better than 99% of what you see out there.

Still, that applies mainly to your code. What if you’re aggregating other people’s code? What if they’re using bad HTML, which their blogging systems (mostly Blogger or WordPress) automatically converts to a feed, which is then converted back to (simplified) HTML by a Planet? And what if you want all of that to validate?

Well, tidy works very well; it fixes the worst problems, mainly, badly nested code, and unclosed tags. But… well, if you’re being pedantic (like the W3 validator is), then there are still problems.

They’re mostly one of the following: 1) img tags without an “alt” attribute, and 2) proprietary attributes.

tidy, by default, doesn’t deal with those (since its point is for you to correct your code, and those problems should really be fixed in the code itself). But you can make it do so.

How? Well, here’s the command line I’m using for Planet Atheism:

/usr/local/bin/tidy -wrap 79 -m -i -utf8 --alt-text "" --drop-proprietary-attributes 1 -asxhtml filename

It should be obvious what each parameter does. The “ alt-text "" ” part adds some empty alt text to any img tag that hasn’t got one. The “--drop-proprietary-attributes 1” part removes those weird attributes inside other tags, which make the W3 validator choke. I don’t want them anyway, since a Planet site is supposed to display a basic version of a post — not a Flash-y, YouTube-d, animated one.

The result is: complete W3 validation, and readable code. From many other blogs, by many different authors. Automatically. What more could anyone want? :)

Adventures with moonmoon and tidy

As I’ve mentioned here before, for Planet Atheism I’m using moonmoon, mostly because 1) everyone else uses planetplanet, and 2) it’s in PHP instead of Python, and I know a little PHP. :)

moonmoon is still on version 0.2, however, and, while it removes “dangerous” tags from feeds automatically, it doesn’t (yet?) deal with unclosed tags. As most of PA’s members are as far from being geeks as possible, they tend to use WYSIWYG editors, and aren’t really worried about “validating HTML”. So, from time to time, a post would make every other post after it show in bold or italic. Annoying, to say the least.

Yesterday, it was even worse: some posts “spilled over” to the sidebar. And it wasn’t just one post causing it, but two, from different blogs, at the same time!

Well, enough was enough.

“Fixing” moonmoon (or, more precisely, SimplePie) was out of the question; I simply don’t know enough PHP / XML parsing to do it. But I tried something else: I saved the generated HTML to a file on the site’s directory, and used tidy on it. Surprise: this new version was perfect! So, I got the idea of using tidy on the generated HTML every time.

Now, PHP has a tidy module, but in PHP5 I would have to compile PHP by hand. Ubuntu doesn’t have a package for that module, unfortunately, and I really didn’t want to make an exception from using apt packages on that server. So, I had to find another way.

My solution was to dump all the page into a buffer (using the ob_ functions in PHP), save it to a temporary file, use the system command to apply tidy on it, load the altered file, and show it to the browser. It’s probably not very efficient, but it works… better than I expected, too. It may be a crude solution, but I’m proud of it anyway. ;)

Blog moved

I finally had some time today to move Way of the Mind (note the new URL) to my Slicehost virtual server. The new WotM Forum is also up, using MyBB, instead of phpBB like my other two. So far, I’m liking it (MyBB) a lot, though it’s a bit weird to have the entire theme inside the MySQL database instead of normal .php or .css files. :)

Moving the WordPress blog was simply a question of following these instructions. Basically, you go to the WP options in the old blog, change the 2 URL fields to the new address, dump the database, do a search & replace to change any images and other URLs in the database to the new address, import the database to the new server, copy the files, and that’s the proverbial “it”.

As for redirection, there came the eternal dilemma: if you redirect everything, then people will be lazy and keep using the old address (thus wasting your bandwidth); if you don’t, it’s inconvenient, and you lose everything you had in terms of incoming links and SEO.

What I did was to redirect (301, to signify a permanent move) every URL except the front page, which shows a message telling people about the change, and redirects after 5 seconds. I believe that this is the best of both worlds. Any link to an individual post will be redirected transparently, but whoever arrives at the front page will told about the change of address, encouraging them to update their bookmarks.




Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Portugal
Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Portugal