Archive | Development RSS feed for this section

Ubuntu 10.04 LTS server always selecting older kernel despite updates

I hit a really strange issue for some time now with one of my Ubuntu 10.04 LTS servers where, despite doing recent kernel updates (the latest is 2.6.32-33) it always booted into the kernel 2.6.32-28. No matter what I did (update-grub, etc.), the server was sticked to 2.6.32-28.

After searching and reading a lot of posts and wiki pages I still couldn’t find a solution for it (most blogs and wiki pages talk about compiling a new kernel or installing a new one, but none talked about selecting the proper kernel or fixing it manually).

But since I had some other server, that booted into the correct kernel issue, I luckily had some config files to compare. The one that I was after is the “menu.lst” which is a GRUB file and is located at “/boot/grub”. Looking at the menu.lst from the working server and comparing it to the “not working” one, revealed that the “non working” one had UUID’s declared for each server while the working one not UUID but “root (hd0,0)” and hard coded root paths of “/dev/sda3″.

Working config:
[code]]czoxODE6XCJ0aXRsZSAgIFVidW50dSAxMC4wNC4yIExUUywga2VybmVsIDIuNi4zMi0zMy1zZXJ2ZXINCnJvb3QgICAgKGhkMCwwKQ17WyYqJl19Cmtlcm5lbCAgL3ZtbGludXotMi42LjMyLTMzLXNlcnZlciByb290PS9kZXYvc2RhMyBybyBxdWlldCBzcGxhc2gNCmluaXRyZCAgL3tbJiomXX1pbml0cmQuaW1nLTIuNi4zMi0zMy1zZXJ2ZXINCnF1aWV0DQpcIjt7WyYqJl19[[/code]

Not-Working config:
[code]]czoyMzg6XCJ0aXRsZSAgIFVidW50dSAxMC4wNC4yIExUUywga2VybmVsIDIuNi4zMi0zMy1zZXJ2ZXINCnV1aWQJOTgyM2Q1NDAtNmJ7WyYqJl19ZjAtNDY3YS04NjQwLTM5ZDMzYzc1NDRmYg0Ka2VybmVsCS92bWxpbnV6LTIuNi4zMi0zMy1zZXJ2ZXIgcm9vdD1VVUlEPWQ5ZTc5YXtbJiomXX1kOS02ZDUzLTRjYjUtODVkNi1lOWYxZWVhNzEyZjIgcm8gcXVpZXQgc3BsYXNoIA0KaW5pdHJkCS9pbml0cmQuaW1nLTIuNi4zMi0ze1smKiZdfTMtc2VydmVyDQpxdWlldA0KXCI7e1smKiZdfQ==[[/code]

As you can see from the this, the UUID and the root are quite different. I can’t actually explain why this configuration took place on this particular server. This is even more surprising since both servers are being “kept in sync” (with updates and such).

In any case, the resolution (for me at least) was to copy certain parameters over to the “not-working” menu.lst. Those were, the root path (/devsda3), the “root (hd0,0)”, the “groot=(hd0,0)” plus the “kopt=root=/dev/sda3 ro” lines.

It took a long time to fix this issue and and I hope this helps someone else.

Comments { 0 }

svn: warning: cannot set LC_CTYPE locale

Somehow with the recent Ubuntu 10.04 LTS updates or maybe with a subversion update, I received some errors message of the type “locale…”. To be more precise the errors are;

svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LC_CTYPE is UTF-8
svn: warning: please check that your locale name is correct

While all SVN commands still worked, it was something I didn’t tackle with immediately. But today, I set out to fix it. Well, it only took a minute or so :)

So, if you want to fix this all you have to do is to set the “LC_ALL” variable manually. To make it permanent just edit the file “/etc/environment” and add the line:

LC_ALL=C

Save the file and exit the editor. In order for it to apply you have to logout of the current shell session. The next time you log in, the issue with SVN will be gone.

 

Comments { 0 }

Plesk 9.5 and domain is expired

Currently doing some Plesk administration and migration of a couple of servers and run into “domain is expired” errors.

To be frank here, I’m very surprised at how many hosting companies have Plesk deployed, even thought the system has one of the worst user interfaces and to use it is like “searching” instead of “Oh, here it is”. Finding what you need within the Plesk administration is a frustrating task, to say the least.

So, today I was hit with a message of “… domain has expired”. While surprisingly it is easy to “unsuspend” a domain, it is quite the opposite if you are being hit by another message of “The domain is still suspended for the following reason: Domain is expired“.

Now, what? The domain is still expired even thought I just “unsuspended” it? There is no message indicating what you have to do next or what is still causing the domain to be expired. (I already ranted on the usability part, right?)

To make a long story short, the reason why Plesk is reporting the “domain expired” message is that the domain has a expiration date set!

Now, to fix this you have to go into the Domain itself, then click on “Resource Usage” (that icon belongs to the “Statistic” group!!!). At the very button of the Resource Usage page you will find the expiration date setting.

By now, you will probably wonder what the Usability designers of Plesk have been thinking and really wish that someone over at Parallels will get their act together. I wonder, who I can bill my time now, after searching countless of hours for such settings?

 

Comments { 0 }

Installing memcached on Ubuntu for wordpress and phpbb

As an application maintainer you always look for the best performance in your application and website. At one point in your quest for the best performance you will undoubtedly trip over memcached.

In short memcached is (quote); Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load. Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.

That said, installing is a no brainer as well. On Ubuntu you simply need to do the following:

[code]]czo1NjpcImFwdC1nZXQgaW5zdGFsbCBtZW1jYWNoZQ0KYXB0LWdldCBpbnN0YWxsIHBocDUtbWVtY2FjaGVkXCI7e1smKiZdfQ==[[/code]

That’s it. Your system takes care of the rest and you will have your first memcached server up and running. Of course, the final step will be to restart apache in order for php to pick up the changes.

Now, memcached alone is of no good use, if your code/application can’t work with it. Thus here I’ll outline 2 examples.

WordPress: Memcached with the W3C total cache plugin

First off, if you aren’t using the awesome W3C Total Cache plugin you should now run install the plugin immediately (just search for w3 cache in the plugin section of the wordpress administration). Even if you are not using memcached it will boost the performance of your WordPress site manifold.

Now, to enable memcached for your WordPress site is as simple as selecting the memcached option for the cache. with the plugin you can even select what you want to place into the memcached cache. Quit slick.

 

Configuring phpBB to use memcached

Actually it took some time to figure this out, since the setting were not so apparent, so I’m hopping this helps others also. phpBB by default used the local disk for caching. This can be chanced in the config.php file in phpBB folder. Open it and ADD or change the following lines:

[code]]czoyNzM6XCIkYWNtX3R5cGUgPSBcJ21lbWNhY2hlXCc7DQpAZGVmaW5lKFwnUEhQQkJfQUNNX01FTUNBQ0hFX0hPU1RcJywgXCdsb2NhbGhvc3tbJiomXX10XCcpOyAvLyBNZW1jYWNoZSBzZXJ2ZXIgaG9zdG5hbWUNCkBkZWZpbmUoXCdQSFBCQl9BQ01fTUVNQ0FDSEVfUE9SVFwnLCAxMTIxMSk7e1smKiZdfSAvLyBNZW1jYWNoZSBzZXJ2ZXIgcG9ydA0KQGRlZmluZShcJ1BIUEJCX0FDTV9NRU1DQUNIRV9DT01QUkVTU1wnLCBmYWxzZSk7IC8vIHtbJiomXX1Db21wcmVzcyBzdG9yZWQgZGF0YQ0KJGxvYWRfZXh0ZW5zaW9ucyA9IFwnbWVtY2FjaGVcJztcIjt7WyYqJl19[[/code]

Especially the last line with “load_extensions” is important. Save the file and restart apache. Now phpBB will use the memcached server(s). Alone on a board with 800 users I have seen a massive speed improvement.

That’s it. Next up is to get all my CFML apps to work with memcached :-)

Comments { 0 }

Coldfusion: How to pass struct and array in a URL

A user just asked:

I need to pass my array to a webserver. But somehow, the array passed with cfhttp throws an error. Please help

You can not pass a structure or an array in a URL as they are complex values and Coldfusion does not have a way to convert them to simple string values (this is what you need to pass in a URL).

The only way to pass complex values is to serialize the Coldfusion struct or array for the URL. Fortunately, Coldfusion has a built in function called “SerializeJSON” to create a simple string. On the other hand, you can convert the simple string back to a struct or array with “DeserializeJSON”.

Here is a simple example how to pass a 2 dimensional array with cfhttp:

[code]]czozNTc6XCI8Y2ZzZXQgbXlhciA9IGFycmF5bmV3KDIpPg0KPGNmc2V0IG15YXJbMV1bMV0gPSBcImtleXdvcmRzXCI+DQo8Y2ZzZXQgbXtbJiomXX15YXJbMV1bMl0gPSBcIlJhenVuYSwgV29yZHByZXNzLCBUb21jYXRcIj4NCjxjZnNldCBteWFyWzJdWzFdID0gXCJkZXNjcmlwdGlvblwiPntbJiomXX0NCjxjZnNldCBteWFyWzJdWzJdID0gXCJSYXp1bmEgaXMgYSBkYW0gd2l0aCBhIGxvdCBvZiBmZWF0dXJlc1wiPg0KDQo8Y2ZzZXQgdGh7WyYqJl19ZWpzb24gPSBTZXJpYWxpemVKU09OKG15YXIpPg0KDQo8Y2ZodHRwIHVybD1cImZ1bmN0aW9uLmNmY1wiPg0KICAgICAgPGNmaHR0cHBhe1smKiZdfXJhbSBuYW1lPVwianNvbmRhdGFcIiB0eXBlPVwiVVJMXCIgdmFsdWU9XCIjdGhlanNvbiNcIj4NCjwvY2ZodHRwPlwiO3tbJiomXX0=[[/code]

Comments { 0 }

Coldfusion and invalid XML character

Today I had a “banging my head to the wall” time where I was confronted with this pesky error:

“An invalid XML character (Unicode: 0×0) was found in the element content of the document.”

Point is that I already created the file in Coldfusion and also used xmlformat for adding the content. So it was “impossible” that there was an error in the content of the XML file. After looking around (yes, Bing or Google is sometimes really your friend) I read that the problem should be some character encoding issue. Since, I already used UTF-8 for writing and reading the file, I thought I had it covered.

Well, to spare you from reading any longer (after all you just came here for the solution ,right?) I figured that I had to escape the control chars before using xmlparse(). In other words, a simple rereplace() was the solution:

“< cfset myxml = REReplace(theXML,'[\x0]','','ALL') >“

Comments { 129 }

Where ideas come from

Steve Johnson talks on “Where ideas come from” gives a good overview how people and especially where they get their ideas from. I personally have been a long time fan of creating an environment where one can cultivate ideas instead of working like a horse. He just emphasizes that socializing creates ideas and being together with others brings out the best. Enjoy.

Comments { 246 }

Synching folder with Amazon S3

The other day I set out to finally start synching one of my backup folders on one of our Ubuntu Servers with Amazon S3. The reasons for this, are obvious. Amazon S3 is very cheap and reliable and is a good fit for keeping “smaller” chunks of files as a backup storage. So, apart from writing a script that runs trough crontab, which was easy to write, I’ve spent far more time to get the S3 script running. So, here are the steps to sync any folder with Amazon S3.

First off, I created a additional bucket on S3. Let’s call this backup “mybackup”.

Since, I did not wanted to install anything additionally to run the S3 scripts (there is a very popular S3Rsync for Ruby out there) I wanted to get it running with the “bash” shell itself. Why install another language, if you got everything already, right?

So, I went ahead and downloaded the S3-bash scripts. As the name implies, these are scripts that work in the bash shell and nothing else is needed for it. Unfortunately, the documentation lacks big time, so I had to run all over the net to find some. Since they are very sparse, here are the steps to get it running.

After you have unpacked the scripts you get three scripts called;

  • s3-get – for getting files from S3
  • s3-put – for putting files on S3
  • s3-delete – for deleting files on S3

Since we want to put files on S3, we are going to focus on the “s3-put” script. Here is a example how the commands for the s3-put script would look like:

s3-put -k {yourkey} -s awssecretfile -T /backup/myfile.zip /s3-backup/myfile.zip

The explanation of the params is as follows:

  • -k
    The “-k” parameter is your Amazon S3 key
  • -s
    The “-s” parameter is a path to a file (which you have to write) which contains your Amazon S3 secret key. Please read further down, in order to avoid any errors with this.
  • -T
    The “-T” parameter should be the absolute path to your file that you want to out on Amazon S3
  • file bucket and path on S3
    Last but not least, you have to pass the path to your S3 bucket and the file name to the command string.

Now, that wasn’t so hard right? Well, there is one small thing that drove me crazy during my initial setup. That is that the file with my Amazon S3 secret key kept on throwing an error. Somehow the length was not matching and some other errors. After some digging around I figured that one has to write to the file again in order to get rid of the 41 bytes error message. To do that issue the following command:

cat awssecretfile | tr -d '\n' >> awssecretfile-new

Right, so I’m hoping this helps anyone out there. Have fun.

Comments { 1,058 }

The future of UI is here

Most of you probably remember the UI of the movie “Minority Report”. We all thought that this would be way cool to interact with our machines like that. Well, good news. The future of the UI is here. The makers of the movie did not only show us what could be done, but also allowed the guys to develop it.

In the below talk, John Underkoffler demoes the UI he and his team has been working on and compares it to the same revolution that once the Macintosh set off when it was introduced. I especially like the quote: “I think it is time that we ask the same of technology. Technology is capable off, expressing and being {…} with a certain generosity. And we need to demand that…”

Comments { 949 }

Jquery form submit and too much recursion

I just run into an issue where the form was submitted with Firefox (despite an error), but the page stopped loading under Google Chrome. With the help of FireBug I saw that there was a Javascript error with the message “too many recursions”.

This is the code that I had which caused too much recursion:

$("#formsignup").validate({
  submitHandler: function(form) {
  // Submit
  $('#formsignup').submit();
}, ...

According to a FAQ buried on the plugin page of Jquery I found that (quote); This results in a too-much-recursion error: $(form).submit() triggers another round of validation, resulting in another call to submitHandler, and voila, recursion. Replace that with form.submit(), which triggers the native submit event instead and not the validation.

Low and behold, I changed my code to the following and it works.

$("#formsignup").validate({
  submitHandler: function(form) {
  // Submit
  form.submit();
}, ...

Hope this helps someone else out there.

Comments { 2,753 }