This is a test for how Google handles an image link followed by a text link that point to the same page. Will the second anchor text get associated with the target link? Or will the alt text of the image be associated and the second anchor text ignored?
First link is an image with alt text:

Second link is text:
dragondabooket
The two made-up words I used are:
pandadabooket
dragondabooket
These terms return 0 results currently. Wonder what happens when I search Google for these two queries tomorrow? If I am right, pandadabooket will point to MusicBrainz, while dragondabooket will not.
If you liked this post, please subscribe to my feed. Thanks for visiting!
I learned today that the client_max_body_size directive in nginx.conf controls Nginx’s upload size limit. The default value appears to be 1MB. To allow uploads of up to 10MB, insert this line in nginx.conf:
I needed to search for full words in strings. strpos() would match parts of a word. Ex. I want to match the word “ass,” but not “assistant.”
Regular expressions to the rescue:
preg_match("/\b$needle\b/", $haystack);
“\b” stands for word boundary. Take care to use the lowercase “\b”, not “\B”, which is the negated version that matches everywhere that “\b” does not.
These are the steps I took to setup multiple hosts for Nginx on a 256MB Slicehost VPS running Gentoo Linux. They should work in other similar Linux environments. YMMV.
I followed this multiple hosts layout intended for a single admin/user, and adapted for Nginx this virtual host permissions setup written for Apache.
Place your user account in the web server (Nginx) group:
sudo usermod -a -G nginx myuser
Logout, login again, check if you are in the “nginx” group by typing:
Create the “public_html” or “htdocs” or whatever directory that will hold all your websites:
mkdir /home/myuser/public_html
Create a directory for your “default” or “catch-all” website:
mkdir /home/myuser/public_html/default
Make sure the “public_html” directory is owned by your user and belongs to the web server group:
sudo chgrp -R nginx /home/myuser/public_html
Make any files and directories created in the future under “public_html” inherit the same ownership and permissions, so you don’t have to set these permissions again:
sudo chmod -R 2750 /home/myuser/public_html
Edit Nginx’s config file:
sudo nano /etc/nginx/nginx.conf
Modify the “server” section to look something like this: (source)
server {
listen 80 default;
server_name _ *;
access_log /var/log/nginx/localhost.access_log main;
error_log /var/log/nginx/localhost.error_log info;
location / {
index index.html,index.htm,index.php;
root /home/myuser/public_html/default;
}
location ~ .*.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:1026;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/myuser/public_html/default/$fastcgi_script_name;
}
}
Start Nginx:
sudo /etc/init.d/nginx start
Set Nginx to automatically start on bootup:
And you’re done! If you need to add another website in the future, simply add another “server” section to nginx.conf.
One of my favorite features of PHP is the tremendous wealth of built-in functions that perform all kinds of useful tasks. Practically any basic operation I ever need to do can be done with a simple PHP function call. This was the case when I needed to remove duplicate values from an array of strings. array_unique() to the rescue.
However, it turns out that for simple dupe removal operations, there are alternatives to array_unique() that perform noticeably faster.
To replace array_unique(), try this faster alternative:
array_flip(array_flip($array))
Note that both functions above leave “gaps” in the resulting array; if $array[2] is a dupe and removed, $array[3] does NOT become $array[2]. If you’d like to reindex/reorder the resulting array, try
array_values(array_unique($array))
And here’s a faster alternative: (source)
array_keys(array_flip($array))
If you’d like to remove case insensitive duplicates, try the following function: (source)
function array_iunique($array) {
return array_intersect_key($array,array_unique(
array_map(strtolower,$array)));
}
Or this faster alternative:
function array_iunique($array) {
return array_intersect_key($array,
array_flip(array_flip(array_map(strtolower,$array))));
}
Sorry for the really infrequent updates. 3-4 hour commutes per day and long work hours is killing my free time.
Merry Christmas to all!
XCache is a PHP opcode cacher created by the same developer who brought us Lighttpd. An opcode cacher significantly increases PHP’s performance by caching the compiled state of PHP code to avoid time-consuming recompilation each time a script is executed. There are a handful of great opcode cachers on the market currently, incuding APC and eAccelerator (here’s a more comprehensive list). APC is written by some of the developers of PHP and will be bundled with PHP6. eAccelerator has a long history and might be the most popular and widely supported opcode cacher. I chose XCache due to its reputation for superior performance (source) and its ability to take advantage of multi-core processors.
Setting up XCache on Gentoo Linux is dead simple.
Install XCache
emerge -va dev-php5/xcache
Configure XCache
nano /etc/php/cgi-php5/ext-active/xcache.ini
Edit anything you see fit. See this page for details.
Since Slicehost is running on twin dual-core processors, I changed “xcache.count” to 5 (n+1 where n is the number of processors) to take advantage of the Splitted Cache feature.
Restart PHP
I have PHP running as a FastCGI daemon, so I restart with
/etc/init.d/fcgi.php restart
Check phpinfo() to verify that XCache is loaded. You should see the following in the “Powered by Zend” box:
with XCache v1.2.1, Copyright (c) 2005-2007, by mOo
Nginx (pronounced “Engine X”) is a high performance web server (and proxy server, but we will be using it as a web server here). In small VPS environments where memory is precious, Apache is at best overkill and uses memory that could be spent elsewhere (like MySQL query caching), at worst a terrible bottleneck that will consistently bring down your site under very moderate loads. If you are willing to live without .htaccess files and Apache-style mod_rewrite rules, Nginx is a great replacement that will lower memory usage and increase performance.
This is a draft. Comments, suggestions, corrections, improvements are very much welcome!
Continue reading ‘Nginx with PHP as FastCGI on Gentoo Linux’