Archive | Development RSS for this section

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?

 

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:

apt-get install memcache
apt-get install php5-memcached

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:

$acm_type = 'memcache';
@define('PHPBB_ACM_MEMCACHE_HOST', 'localhost'); // Memcache server hostname
@define('PHPBB_ACM_MEMCACHE_PORT', 11211); // Memcache server port
@define('PHPBB_ACM_MEMCACHE_COMPRESS', false); // Compress stored data
$load_extensions = 'memcache';

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 :-)

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:

<cfset myar = arraynew(2)>
<cfset myar[1][1] = "keywords">
<cfset myar[1][2] = "Razuna, Wordpress, Tomcat">
<cfset myar[2][1] = "description">
<cfset myar[2][2] = "Razuna is a dam with a lot of features">

<cfset thejson = SerializeJSON(myar)>

<cfhttp url="function.cfc">
      <cfhttpparam name="jsondata" type="URL" value="#thejson#">
</cfhttp>

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') >“

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.

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.

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…”

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.

Nginx error with Tomcat – upstream sent too big header while reading response header from upstream

Nginx is our favorite web server currently as it is fast, lean and easy to configure. Performance is just outstanding and if you haven’t take a look at it.

One thing that I noticed while we deployed Nginx with Tomcat is that their default size for the buffers are very low. Don’t know why a 4K buffer size would be sufficient. If you keep it at their default size and might have a heavy duty Tomcat app then it could be that you will see error messages like:

upstream sent too big header while reading response header from upstream

The remedy for this error is to set the parameters for higher values for the proxy_buffer* parameters as we have done and now all is back to normal. Here are the current settings that worked well for us;

proxy_buffer_size   128k;
proxy_buffers   4 256k;
proxy_busy_buffers_size   256k;

Setting up Apache2, PHP and MySQL on MacOS X – the easy way

Today I set out to get MySQL and PHP setup on my MacBook Pro. Since Apache2 already comes with MacOS X (mine is Snow Leopard and yours should be too!). Now, the funny thing is that I first searched on the web how to best install PHP and MySQL.

Surely, I came across MAMP (a package that gets you Apache2, PHP, MySQL and a couple libraries) in a nice one click application and some others. Being the guy who rather has things separated and controllable, I quickly shined away from those. Thought, I gave MAMP a try, but could not get MySQL to listen to anything else then the internal Apache2 server from the MAMP package (but guess that is another story and I’m really not doing this the first time.). Anyhow…

I then looked into getting Apache2, MySQL and PHP with MacPorts. Thought MacPorts has proven to be perfect in such circumstances, I had a hard time (and it took very long) to get this setup up and running. I’m sure, some of you have had successful installs and all works great, but at the end it did not work for me. There are even more instructions to get PHP running, with a lot of tweaking and such, but to be honest in the end…

Really the simplest and most straightforward method to get Apache2, MySQL and PHP running on MacOS X is;

MySQL

Now, this is really no brainer. All you need to do is to go to http://www.mysql.com and download the recent release. Within the download image you will find a nice installer and Preference pane which lets you start/stop MySQL. If you want to go all GUI, then also download the GUI tools from MySQL.

Apache2/PHP

The probably easiest of it all. Since MacOS X already comes with Apache2 and PHP all you need to do is to enable it. Thought, PHP is disabled in the httpd.conf, all there is to do is to edit httpd.conf and uncomment the mod for the php library.

That’s it!

Nothing to install, (almost) nothing to configure. Simple and easy.