Subversion 1.7 on Ubuntu 12.04

Ubuntu’s default packages ship Subversion 1.6 with the 12.04 distribution. This is annoying if you want to use the newer Subversion 1.7, without upgrading your OS, and especially if you’re dealing with newer working copies:

svn: The path '.' appears to be part of a Subversion 1.7 or greater
working copy. Please upgrade your Subversion client to use this
working copy.

Turns out there’s an official Subversion PPA on Launchpad, so for Ubuntu 12.04 all you have to do is add the following couple lines to your /etc/apt/sources.list file:

deb http://ppa.launchpad.net/svn/ppa/ubuntu precise main 
deb-src http://ppa.launchpad.net/svn/ppa/ubuntu precise main 

And upgrade Subversion to its latest version with apt-get:

sudo apt-get update
sudo apt-get install subversion

At this point you should be running the latest, and the greatest:

$ svn --version
svn, version 1.7.8 (r1419691)
   compiled Mar 23 2013, 23:38:40

Hope this helps!

Gnome 3: An Alternative to Unity in Ubuntu 11.10

My wife has got a Sony Vaio netbook, which we bought a year ago. The whole point was to get a lightweight laptop for Internet access, e-mail and documents, so no development VMs or gaming station. The operating system chosen was Ubuntu, at that time it shipped with Gnome.

Ubuntu 11.10 Gnome 3

However, due to some (relatively) recent updates to Ubuntu (as of version 11.04) it ships with Unity, and as of 11.10, they stopped shipping Gnome. I think Unity is good if you’re running an 8-core station with a good graphics card, but from what I heard, Unity was designed for tablets and netbooks, and it looks like somebody forgot that tablets and netbooks don’t have the horsepower of desktop workstations.

After months struggling with Unity on my wife’s netbook, it only became worse. It started freezing several times a week (that’s a lot for Linux) and it took minutes (that’s a lot for Linux) to boot up. I thought of wiping the whole thing and starting clean with Ubuntu 10.11, but then I decided to give it another chance, by installing Gnome 3.

sudo apt-get install gnome-shell

Which actually saved me from the headaches of having to reinstall a bunch of software, backup a bunch of documents, photos and videos. Gnome 3, together with some old software cleanup, gave our netbook a new life. After a reboot I was able to log into a Gnome session (as seen from the screenshot above) and everything was literally flying! Hope this lasts for at least a year, hat tip to virtualhelp.me.

I can’t say I’m really loving Gnome 3, and Unity was okay from the user interface and experience point of view, but when your system becomes slow because of a desktop manager, you’ll have to switch or upgrade, no matter how funky the UI is :)

Have you had trouble with performance and Unity in Ubuntu Linux? What was your solution? I read a few forums where many people were looking to switch to other Linux distributions, what’s your take on that?

Thanks for stopping by and subscribing!

Sync Time and Date in Ubuntu Linux

Quick tip! If you’re using virtual machines to develop and test your web applications, you probably use the “save state/snapshot” feature instead of turning it off and on every time. I noticed after a while that my time was out of sync (a few weeks late) which caused a bunch of problems. Luckily, I found this simple command:

sudo ntpdate ntp.ubuntu.com

It will sync your time with the Ubuntu Time server. You can even add a cron entry as suggested by this article. To display the current time and date, simply type date. Hope this helps :)

Ubuntu 11.10 Wireless on Sony Vaio with RT3090

Updated my Sony Vaio VPCM12M1R netbook to Ubuntu 11.10. The update went quite smooth although wireless immediately stopped working. Well it didn’t quite work with Ubuntu 10.10 either but the RT3090 package fixed it last time. Luckily I didn’t remove the package and was lucky to get things working on 11.10 simply by:

sudo dpkg -i rt3090-dkms_2.3.1.3-0ubuntu0~ppa1_all.deb

And obviously rebooting the netbook. Everything’s back to normal now so yeah, yet another successful Ubuntu upgrade. Loving the changes to Unity in 11.10!

Regex Replace in MySQL or lib_mysqludf_preg in Ubuntu Linux

I’ve been working a lot with MySQL lately, especially after the major theme and plugin upgrades on my blog. I was dealing with a bunch of content issues like redundant shortcodes and post meta, URL changes, images directories and more.

One simple solution would be to grab the database dump, perform various search and replace operations and then feed it back in, and my goal was to do that without data loss, without going offline, without sending files back and forth but mainly for learning purposes.

I found a UDF for MySQL called lib_mysqludf_preg and here’s how I got it to run on Ubuntu 11.04, somewhere in a temporary directory:

sudo apt-get install libpcre3-dev libmysqlclient-dev
wget http://www.mysqludf.org/lib_mysqludf_preg/lib_mysqludf_preg-1.0.1.tar.gz
tar -xf lib_mysqludf_preg-1.0.1.tar.gz
cd lib_mysqludf_preg-1.0.1
sudo ./configure
sudo make install
sudo service mysql restart

So, install some libraries upon which the UDF may depend, download the UDF archive, extract it, browse to what has been extracted, configure, install and restart MySQL (just in case.) If you’re reading this and it’s not 2011, make sure you get the latest version and read the release notes too.

At this point the UDF library is installed but the functions are not available yet, so log in to your MySQL command line, preferably as root and create your new preg_replace function like this:

CREATE FUNCTION preg_replace RETURNS STRING SONAME 'lib_mysqludf_preg.so';

Voila! And here’s how I removed a shortcode from all posts and pages:

UPDATE wp_posts
  SET post_content = PREG_REPLACE('/[my_shortcode*?.*?]/', '', post_content)
  WHERE post_content LIKE '%[my_shortcode%';

Make sure you backup your database first though before doing any of this. I did! But everything went fine. My next goal is to get the shortcode provided by a syntax highlighting plugin replaced with a <pre> tag. Hopefully I won’t break anything so good luck to me and thank you so much for stopping by!

Lesson Learned: Backup Before Upgrading

Friday started with off quite crazy with a surprise from my web hosting server. I don’t really know why but I decided to run an apt-get upgrade last night and everything seemed fine until this morning when I was unable to log back on via SSH. So what did I do? Reboot, obviously and it broke everything. Ping was lost, services are down, websites not working, oh my!

I know my web hosting provider wouldn’t help much since I’m renting a virtual private server with root access which comes with a lot of responsibility, besides I was quite sure I’d handle it faster than I would have opened a support request and described the details, and I did!

Luckily I was able to use the Change OS feature and grabbed Ubuntu 11.04 which was installed within 20 minutes with all my old files in the /old directory. The rest was up to my typing speed — install necessary software, copy the old MySQL databases, restore the users, set up nginx and php-fpm and voila. I was back online. Approximate downtime: 45 minutes.

Lesson learned: backup your full VPS container before upgrading. Thank you Media Temple for providing the freedom to break things and the tools to fix them :)

An Almost Smooth Upgrade to Ubuntu Linux 11.04

Right, we all heard it! Ubuntu 11.04 is out, with the new Unity bundled. I was excited to hear the news and I rushed to run the upgrade on my PC at work, which luckily has an Nvidia graphics card. I can’t believe the upgrade took so long (around two hours) but in the end, seems like it was worthed.

Welcome to Unity, thought I.. Yeah, it was nice and shiny, smooth and all y’know, looked like Mac OS. I got tired of it after a few hours of usage, but promised myself I would ride it for a couple of weeks before switching back to the good old interface.

Together with a bunch of other software upgrades, came Firefox 4 and for some reason became the default browser without ever asking me! Yeah, nice.. but okay, where’s my Chromium? And Chromium keeps asking me whether to make it my default web browser every time I launch it, although I said “Yes” like a bizillion times.. Oh well, nothing’s perfect in the open source world ;) But wait, there’s more! I loved the upgrade I did at the office so much that I decided to carry it out on my home PC as well, so I did! Unfortunately, I did.

I got an ATI Radeon graphics card, which worked very well in versions 10.04 and 10.10, had all the desktop effects and 3d stuff, everything was working like a charm! So after my upgrade to Ubuntu 11.04 I got the blank screen a couple of times, and the whole interface was lagging so bad, that I had to turn off all desktop effects including Unity, and actually switch back to the old desktop interface, although that didn’t help much either.

Anyhow, the usual bundle is still working: PHP, MySQL, Python, Django, Apache and Nginx and all the relevant. I’m thinking to upgrade my Ubuntu Server to the latest, but I guess I can wait ;)

So the bottom line here is — there’s always going to be new stuff and we’ll just have to adapt to it, this applies to Unity and the fact that we’re used to seeing our launched applications in a “taskbar” at the bottom of the screen. And don’t upgrade to Ubuntu 11.04 just yet, if you’ve got an ATI card, unless you find somebody who successfully did ;) Cheers!

Update: If you’re running Unity on a different theme than the default, it looks and feels aweful, the window control buttons at the top left are awkward, so if you’re experiencing this go to Appearance and change your theme to Ambiance (I guess).

Installing Python 2.5 on Ubuntu Linux 10.10

If you’ve been working on App Engine and you’ve noticed that some stuff works on your development server but not on your production, it may be related to the different versions of Python. Latest linux builds including Ubuntu 10.04 and 10.10 come with Python 2.6 pre-installed, but Google App Engine still runs Python 2.5 (an issue has been created to add Python 2.6 support, make sure you vote that up).

Their roadmap mentions nothing about upgrading. So in order to make your development server look more like your production servers, you’ll have to get Python 2.5, which is not that trivial at first.

So, Felix Krull has published an archive of new and old Python packages, so let’s use that source to get Python 2.5 running on a new Ubuntu box:

sudo add-apt-repository ppa:fkrull/deadsnakes
sudo apt-get update
sudo apt-get install python2.5

Yup, that was easy! Let’s now see if both Python 2.5 and Python 2.6 are available:

$ python2.5
Python 2.5.5 (r255:77872, Sep 14 2010, 15:51:01)

$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)

All done! Oh and don’t forget to launch your App Engine development server using python2.5 (installing it is not enough):

$ python2.5 dev_appserver.py .

As a bonus to this post, I’d like to share with you my way of working with App Engine, not in terms of code, but in terms of libraries organization. If you’re writing code for App Engine you’re probably working on more than one project at a time, hence you’ll need to use the SDK more than once.

So instead of copying it, replacing Python packages, etc, simply move the google_appengine folder to /usr/share and in every App Engine project create a symbolic link called .gae that points to that location. The SDK will automatically locate all the Google libraries and the development server is easy to launch:

$ ln -s /usr/share/google_appengine/ .gae
$ python2.5 .gae/dev_appserver.py .

Don’t forget the dot at the end, since it tells the SDK which project to launch. And make sure you don’t push the .gae directory to your source control ;) Happy coding!

Upgrading Django on Ubuntu Linux

As I wrote on Twitter a couple of times, I’ve been exploring the world of Django during the latest few weeks. I’m quite impressed with the framework, although there are some issues I’m not yet used to. This post is a short snippet for the Ubuntu users that are struggling with upgrading to the latest Django package. I’m not sure about other Linux distros, but the latest Ubuntu installs django 1.1 which is quite old nowadays. So if you’ve installed Django the following way on Ubuntu:

sudo apt-get install python-django

You’re probably running an outdated version too. Now, to fix this you’ll have to get something newer as a tarball package from the Django Download section and follow the install instructions, which basically run the python setup tools to install the package. After everything’s done, there’s just one minor issue. You have to remove your old django installation as it has a higher priority for python. Use the following code to remove your old version:

sudo apt-get remove python-django

Also note that django may be left somewhere around /usr/local/lib/python2.6/dist-packages/ so make sure you remove the outdated versions from there too. Then run the python interpreter and print out the current version of Django. Make sure that you see something similar:

import django
django.VERSION
# Outputs: (1, 2, 3, 'final', 0), hurray!

Driving the (ve) Server at Media Temple

It’s been a few weeks now since Media Temple launched their new (ve) Server and I’ve been testing it out for a few days now. I’m actually hosting my blog there to experience some real traffic load and my first impressions are awesome!

I started off with the simplest 512 MB server and transferred a few websites to the new platform. I’m not too used to the Ubuntu Linux operating system but I found my way around quickly. They do have other operating systems options, but Ubuntu is the one they recommend. First few tests showed that my load time decreased dramatically compared to my Amazon EC2 instance, which I was quite happy with. Next step was to run a few load tests using the Apache Benchmark tool (ab), and very soon I realized that I got quite a few failed requests, memory shortage and other strange stuff.

Media Temple’s (ve) servers are hosted on the Virtuozzo platform by Parallels, and after browsing their documentation I found out that there’s no swap space available for Virtuozzo containers. They do allow around 80% of burstable RAM (so you get around 1 GB when running 512 MB) but when that runs out, you’re left with nothing, not even some swap space on your hard drive. Some heavy load tests showed 30% request failure, which is quite horrible.

Media Temple don’t give much information on the new platform via the support system and in memory shortage questions in their user forums they advice you to upgrade, of course! Well, I wouldn’t like to upgrade to just run a couple of load tests, and what about Digg-traffic? Should I predict that and upgrade before the spike? Then downgrade again to save some cash? Of course not.

A good option I found here is to tune Apache a little bit, reduce it’s resources limits. This will not increase performance, but may guarantee a 100% fail-safe workflow. We wouldn’t like our users to see a blank page (or a memory shortage error) when a spike hits, but we would rather want them to wait more than often and still load the requested page. The settings mostly depend on what software you’re running, which services and the RAM available in your container.

You might want to reduce the KeepAliveTimeout in your apache settings (mine’s now set to 5), and the rest is up to the mpm prefork module. You’ll have to modify your settings and then run some tests until you’re comfortable with the results. Mine are the following:

<IfModule mpm_prefork_module>
    StartServers 3
    MinSpareServers 2
    MaxSpareServers 5
    MaxClients 10
    MaxRequestsPerChild 0
</IfModule>

This is on a 512 MB (~ 400 more burstable) container. An Apache Benchmark test showed that 100 concurrent (simultaneous) requests performed in 26 seconds with 0% failed requests, this makes 3.84 requests per second, which is quite good. To give a comparison, the same test ran on the mashable.com website gave 30 seconds with 3.32 requests per second, and of course a 0% failure. Also check out other MPMs for Apache which could give results too.

This definitely requires more fine-tuning and if the page load time becomes too high then yes, there is a reason to upgrade, but don’t forget about other performance tricks such as CDNs, gzip (deflate) and others. When you’re done with Apache, proceed to MySQL fine-tuning & php configuration, there are some tricks there too to give you some extra speed & performance.

I’ll keep playing around with this server, plus I’ve purchased a 1GB (ve) this morning, so there’s quite lot of tests that have to be run. Anyways, if you’re looking for a good, high-performance VPS, then Media Temple is definitely a choice to consider. For only $30/mo you can get quite a good looking virtual server. It is more interesting than their old dedicated virtual servers (although still in beta). Cheers, and don’t forget to retweet this post ;)