There are things I dislike about Ubuntu Linux, like the inability to customize during installation and the silly orange theme, but I had always thought that Ubuntu was the very best representative from the Linux world for mere mortals. Alas, Ubuntu has failed to live up to this expectation of “everything just works” in a big way. Ever since Adobe’s release of Flash 9.0 update 3 (9.0.115.0) codename “Moviestar” on December 4th, it has been impossible to install Flash through conventional means like the Add/Remove panel, Firefox’s plugin installer, or Synaptic.
Flash is one of the essential applications that every normal computer user must have nowadays. For a typical computer user to be unable to install Flash for a month (and counting) on a major operating system is frankly ludicrous. I’ve always scoffed at those who claim that “every Linux distribution sucks; *insert my favorite distro* just sucks less.” But this time, I can’t help but agree. (For the record, Ubuntu is not my favorite, but it is the easiest to install and use and my distro of choice at the office.)
Read more about this Flash bug here.
P.S. In my eyes, Mozilla Firefox is still the lone shining jewel in the arena of open-source software for end-users. Everything really “just works” and when problems arise, like the recent regressions, they get fixed in a hurry and pushed out with a fool-proof automatic update mechanism. All hail the Mozilla wizards.
If you liked this post, please subscribe to my feed. Thanks for visiting!
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!
“A three-pronged attack on performance” is a good read on improving performance in Linux. One performance enhancing setting is the hard disk’s readahead value. Unfortunately, there is no magical readahead value that will optimize your hard disk’s performance; you must run your own benchmarks. I used the following code to benchmark disk performance (12 times) at each readahead value on my 256MB Slicehost VPS.
for ((i=0;i<12;i++)); do sudo hdparm -t /dev/sda1; done
The average disk read speeds at each readahead value are as follows:
“hdparm -a128 /dev/sda1″ - 65.69 mb/sec
“hdparm -a256 /dev/sda1″ - 104.44 mb/sec
“hdparm -a512 /dev/sda1″ - 114.54 mb/sec
“hdparm -a1024 /dev/sda1″ - 119.39 mb/sec
“hdparm -a2048 /dev/sda1″ - 122.82 mb/sec
It appears that on my Slicehost VPS, “hdparm -a2048” yields the best performance. To ensure that this readahead value is used at all times, I instruct hdparm to set it on every bootup by adding the following line to /etc/conf.d/local.start
More details and documentation on Slicehost’s Wiki.