Thursday, November 04, 2010

FULLTEXT search in MySQL DB does not return any result, but works fine in BOOLEAN mode

Well, that was a trap... First, I found that a simple query like
SELECT * FROM `articles` WHERE MATCH(title) AGAINST('jerusalem')
returns 0 rows on my development DB.
Next, I found that the same Native Language SQL query works just fine on the production DB with the real data.
Third, I discovered that the same query works just fine on both DBs when BOOLEAN search is used:
SELECT * FROM `articles` WHERE MATCH(title) AGAINST('jerusalem' IN BOOLEAN MODE)

The reason was that I got only two records in my development DB! So any Natural Language search failed there into the 50% 'common keywords' rule stated in MySQL manual:
A natural language search interprets the search string as a phrase in natural human language (a phrase in free text). There are no special operators. The stopword list applies. In addition, words that are present in 50% or more of the rows are considered common and do not match. Full-text searches are natural language searches if no modifier is given.

With just two rows any keyword was considered by MySQL as common! The obvious solution was adding one more empty row. And voila! - we got the search results.

It looks like this 50% rule can not be switched off by MySQL configuration. If you know how to switch it off drop me a note, would love to do that in my development environment.

Friday, October 22, 2010

Installing WP in a separate folder

Clear instructions by the Wordpress team how to get WP installed in its own directory.

Wednesday, October 06, 2010

Downgrade AWS AMI instance to the new 'micro' AMI

AWS prices for micro AMIs clearly show the costs advantage to run a micro instance for a low-volume site.
Furthermore, you can build the entire scalable IT system on micros, and then just scale up the nodes that have to be scaled.

Unfortunately, migrating to the new micro AMIs it is not that simple. There is no simple way to convert your exiting small or medium AMIs to micros if these AMI were created a while ago and use S3 as their instance store.
You can easily convert your existing AMI to micro using AWS console if your AMI is
a) Linux based
b) EBS (and not 'instance-store'/S3) based. Since 'EBS-root' is quite a new AWS feature many existing AMIs are S3 based, so here the story starts.

If you got a S3-based instance the migration to micro AMI is not that simple.
Of course you can start a new micro instance and install there anything from scratch (it will be automatically created as an EBS instance).
If starting from the scratch is not an option, you can try to follow unofficial guides for converting an S3-based instance to an EBS instance. If the conversion is successful AWS console will allow to create a micro instance from your EBS-hosted AMI.

There are only three blog posts providing some help in S3 to EBS AMI conversion (I did not try any of them yet, none of them looks like an easy way to go):
http://www.elastician.com/2009/12/creating-ebs-backed-ami-from-s3-backed.html
http://www.full360.com/blogs/Migrating-Linux-S3-Based-AMI-EBS-Based-AMI
http://coderslike.us/2009/12/07/amazon-ec2-boot-from-ebs-and-ami-conversion/

I wonder why AWS  did not provide a 'ec2-' tools script and/or console support for these S3-to-EBS-root conversions.

Saturday, September 04, 2010

To see all open (listening) ports in Linux

Run
netstat -ntulp
or
lsof -i -n -P
for some more info

Wednesday, September 01, 2010

Apache/ PHP (XAMPP) does not recognize

Well, when I knew how to write the title of the post I already solved the problem.

After the new XAMPP install with PHP 5.3.4 my PHP code stopped to work, interpreting here and there like plain text. I was not sure what is going on: is that Savant who can not work with PHP 5.3.4 or anything else.

The problem was that this XAMPP install switches off 'short_open_tag' parameter in php.ini. Once I fixed it and restarted Apache everything worked just fine.

Apache (XAMPP) does not start: Virtual Hosts: "Directory path is invalid" - Windows 7

When installing and configuring XAMPP on Windows 7 64-bit I found a few issues.

One well known thing is that Apache fights with Skype for ports 80 and 443, who gets them first.

The solution is simple: just tell Skype not to use ports 80 and 443 - uncheck the box.



Another, a more complicated issue came the next. Once I get Apache running and successfully showing me the XAMPP welcome page, I found that Apache does not run with my virtual hosts file.

On Windows 7 Apache fails with 'path is invalid' message in 'error.log' if some directories are defined as 'Shared' in Windows Explorer. The strange thing that they also could be 'nearby' folders to the path, defined as a virtual host root.

For instance, if I have C:/Development/Project_1 and C:/Development/Project_2, Apache will fail to start with Virtual Host defined in C:/Development/Project_1 if C:/Development/Project_2 is shared.
Weird, but verified - it works this way.
A possible explanation can be that I also have 'Development' shared, so having 'Project_2' shared is like a 'nested-sharing', which obviosly is a nonsense practically speaking, but probably can confuse the OS / Apache. Just a thought.

Now, if you have a fairly complicated folders tree and some folders are defined as shared it's very difficult to find what is going on and what folders disturb you.

The solution:
I just recreated the whole 'Development' tree in a separate folder 'Dev'. Being moved, the folders get a OS warning that sharing will be disabled. The new 'Dev' tree with no folders sharing solves the problem with Apache, and after removing all the old folders I renamed 'Dev' back to 'Development', restoring my previous environment.

Friday, July 02, 2010

Multilingual Wordpress SEO plugin for WPML

It appears that All-in-one-SEO plugin for WordPressdoes can not work with WPML multilingual CMS plugin.
Too bad, since we obviously have to manage our titles, descriptions and keywords in different languages if the pages appear in different languages.
So I had to switched from All-in-one-SEO to something else that supports WPML and can add multilingual titles for multilingual pages, like English title for English pages and Russian titles for Russian pages.

I was told that HeadSpace plugin works fine with WPML. The quick test showed that it is correct.

The bad thing was that I already had added English titles to more than 100 posts and pages using All-in-one-SEO, and this titles did not show up if I use HeadSpace.
What I do now? Should I retype all the titles again for teh new plugin.
I took a quick look on my WordPress database and reviewed the content of "wp_postmeta" DB table. All I needed was just replacing the field's name for title and description!

These 2 lines of SQL convert titles and descriptions from All-in-one-SEO to HeadSpace:


update wp_postmeta set meta_key = replace(meta_key, '_aioseop_title', '_headspace_page_title')
update wp_postmeta set meta_key = replace(meta_key, '_aioseop_description', '_headspace_description')