Changing ip address on Ubuntu server

Easy as pie:

CODE:
  1. ifconfig eth0 192.168.5.120 netmask 255.255.255.0 up
  2. route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.5.1

Kruidvat fotoservice installeren op Ubuntu 12.04 (Precise Pangolin) / Linux

Ik wilde een paar foto's afdrukken op een groot formaat en het was eerste paasdag. Dus toen ben ik maar gaan zoeken naar fotosites die Linux ondersteunen. 1 van de weinige die Linux (een beetje) ondersteunt is Kruidvat.

Zij bieden losse software aan die op Linux draait. Dat klopte maar ik moest wel eerst nog wat (aparte) dingen installeren voordat de fotosoftware van Kruidvat werkte op Linux:

CODE:
  1. sudo apt-get install libstdc++6:i386 libfontconfig1:i386 libsm6:i386

Vervolgens de software zelf nog even:

CODE:
  1. wget http://www.kruidvat.nl/fotoservice/bestelsoftware-download-windows-download-windows-start.html?version=linux
  2. tar -xzvf setup_Kruidvat_fotoservice.tgz
  3. ./install.pl

Kruidvat fotoservice op Ubuntu Linux

Daarna kwam ik erachter dat Pixnum ook Linux ondersteunt met verschillende uploaders (Flash, FTP & Java) en goedkoper is dan Kruidvat. Toen waren de foto's echter al besteld. Misschien voor de volgende keer dus.

motorrijweer.nl

Ik heb de eerste versie van motorrijweer.nl live gezet! 't Is nog vrij basis maar je kunt wel al voor een paar regio's het motorweer/motorrijweer opvragen. Op naar de volgende versies!

Motorrijweer / motorweer

Combining 4 images and aligning them next to eachother

The workflow: make two new images out of 4: combining 2x2 to make hdr's. Then aligning them

CODE:
  1. sudo apt-get install hugin-tools enfuse
  2. enfuse DSC_166* -o 1.jpg
  3. enfuse DSC_167* -o 2.jpg
  4. align_image_stack -a test.jpg 1.jpg 2.jpg

Then I put them next to eachother in GIMP :p

 

The continuing story of Zend Studio 5.5.1 (part 2)

Everytime I install a new version of Ubuntu / Linux I'm hoping Zend Studio (the old/good one) will still be working. This time with Ubuntu 12.04 I again had to do this but it didn't take longer than a couple of minutes.

First I had to install the java executable (otherwise I got a "java: not found" error message. Because the Sun JRE isn't available anymore for Ubuntu (12.04) I installed the default one (icedtea I believe). To my amazing that worked perfectly!

Then I had to install some (i386) libs and it worked! libxcursor is need or else you'll get a really ugly cursor in Zend Studio 5.

CODE:
  1. sudo apt-get install default-jre
  2. sudo apt-get install libc6-i386 libxp6:i386 libxtst6:i386 libxcursor1:i386
  3. ln -s /lib32/libc.so.6 /lib/libc.so.6

msmtp and the aliases file (/etc/aliases)

Since version 1.4.25 msmtp has support for a aliases file. I edited my ~/.msmtprc and added:

CODE:
  1. aliases ~/.aliases

~/.aliases:

CODE:
  1. root:           myemail@mydomain.tld

Only ~/.aliases didn't get expanded to the full path:

http://sourceforge.net/mailarchive/forum.php?thread_name=1330871670.3229.1.camel%40polly&forum_name=msmtp-users

Other than that, it worked perfectly! Now I can send e-mails to root and have them delivered to my personal e-mailaddress.

Removing the password from an (open) ssl key

CODE:
  1. openssl rsa -in www_silverpower_nl.key -out www_silverpower_nl.key.unencrypted

Securing chromium-browser with apparmor on Ubuntu 11.10

I wanted to make chromium (chrome) more secure. Just to be safe. I found out that the package apparmor-profiles on Ubuntu contained an apparmor profile for chromium-browser. I installed it and tried to enforce it without using the aa-enforce binary (which required the apparmor-utils package) but I couln't get that to work. So I installed apparmor-utils anyway.

CODE:
  1. sudo apt-get install apparmor-profiles apparmor-utils
  2. sudo aa-enforce /usr/bin/chromium-browser /usr/lib/chromium-browser/chromium-browser

When all is done, quit the chromium browser and restart it. Then, when you run aa-status it should list chromium-browser as 'enforced'.

I tried to do the same thing for /usr/sbin/dovecot but that didn't quite work. Dovecot threw errors like:

CODE:
  1. init: dovecot main process (8738) terminated with status 84

I tried fixing it but I didn't get it to work so I gave up.

dump a Varien_Db_Select / Zend_Db_Select query

CODE:
  1. $query = $adapter->getProfiler()->getLastQueryProfile()->getQuery(); //print last executed query
  2. foreach ($adapter->getProfiler()->getLastQueryProfile()->getQueryParams() as $k => $v) {
  3. $query = $query = str_replace($k, "'{$v}'", $query);
  4. }
  5. var_dump($query);

A more complete example:

CODE:
  1. $adapter = Mage::getSingleton('core/resource')->getConnection('core_write');
  2. $adapter->getProfiler()->setEnabled(true); //enable profiler
  3.  
  4. // Do database stuff
  5.  
  6. $number = 10;
  7. $profiles = $adapter->getProfiler()->getQueryProfiles();
  8. $profiles = array_slice($profiles, count($profiles)-$number, $number);
  9.  
  10. foreach ($profiles as $profile) {
  11. $query = $profile->getQuery(); //print last executed query
  12. foreach ($profile->getQueryParams() as $k => $v) {
  13. $query = $query = str_replace($k, "'{$v}'", $query);
  14. $query = preg_replace('/\?/', $v, $query);
  15. }
  16. var_dump($query);
  17. }

Nginx + sabnzbd + sickbeard + couchpotato + spotweb on my pandaboard

I got Apache- (mpm-itk), sickbeard, sabnzbd, couchpotato and spotweb running on my pandaboard. But apache really used up a lot of resources. So I decided to replace it with nginx. Nginx would be a reverse proxy and communicate via fastcgi with php.

This post describes how to set up Nginx. Not how to install sabnzbd, sickbeard, couchpotato or spotweb on your machine. I assume you know how to do that.

Step 1: install nginx

CODE:
  1. leon@panda:~$ sudo apt-get install nginx-light

Step 2: proxy stuff

Add all the important proxy stuff in one file so it can be included later on.

leon@panda:~$ cat /etc/nginx/conf.d/proxy.conf

CODE:
  1. proxy_redirect off;
  2. proxy_set_header Host $host;
  3. proxy_set_header X-Real-IP $remote_addr;
  4. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  5. client_max_body_size 10m;
  6. client_body_buffer_size 128k;
  7. proxy_connect_timeout 90;
  8. proxy_send_timeout 90;
  9. proxy_read_timeout 90;
  10. proxy_buffers 32 4k;
  11.  
  12. allow 192.168.1.0/24;
  13. deny all;

Step 3: set up all the locations

Set up alle the locations (subdirectories on you http server) for sabnzbdplus, sickbeard, couchpotato and spotweb.

The important part from /etc/nginx/sites-enabled/default:

CODE:
  1. server {
  2.  
  3. location /sabnzbd {
  4. include /etc/nginx/conf.d/proxy.conf;
  5.  
  6. proxy_pass http://localhost:9090;
  7. }
  8.  
  9. location /sickbeard {
  10. include /etc/nginx/conf.d/proxy.conf;
  11.  
  12. proxy_pass http://localhost:8081;
  13. }
  14.  
  15. location /couchpotato {
  16. include /etc/nginx/conf.d/proxy.conf;
  17.  
  18. proxy_pass http://localhost:5000/;
  19. rewrite ^/couchpotato/?$ /couchpotato/movie/ permanent;
  20. }
  21.  
  22. location /spotweb {
  23. alias /home/leon/src/spotweb/spotweb.git; #not root directive
  24.  
  25. location ~* \.php$ {
  26. fastcgi_pass localhost:9001; #defined in /etc/php5/fpm/pool.d/leon.conf
  27. include fastcgi_params;
  28. fastcgi_index index.php;
  29. }
  30. }
  31.  
  32. }

Sorry about the indentation... Anyone recomend a good code plugin for wordpress?

Step 4: setup php

Now we're going to set up php for nginx with php5-fpm. This is a new module and isn't available on older versions of ubuntu. I think it's only available from ubuntu 10.10 and onwards.

CODE:
  1. leon@panda:~$ sudo apt-get install php5-fpm

Then edit /etc/php5/fpm/pool.d/leon.conf (in my case). I created another pool for my user ('leon') because I don't want it to run under the user www-data or similar.

cat /etc/php5/fpm/pool.d/leon.conf

CODE:
  1. ; Start a new pool named 'leon'.
  2. [leon]
  3. listen = 127.0.0.1:9001
  4. user = leon
  5. group = leon
  6.  
  7. pm = dynamic
  8. pm.start_servers = 1
  9. pm.min_spare_servers = 1
  10. pm.max_spare_servers = 4
  11. pm.max_children = 4

Step 5: Restart everything and admire your work

CODE:
  1. leon@panda:~$ sudo service nginx restart
  2. leon@panda:~$ sudo service php5-fmp restart

Footnotes:
I also tried to get it working with chroot = /home/leon in /etc/php5/fpm/pool.d/leon.conf but I couldn't get spotweb working with mysql on port 3306. When chrooted you can't access /var/run/mysqld/mysqld.sock. I'll have to investigate that a bit more.

Also, you could remove /etc/php5/fpm/pool.d/www.conf if you don't use it (like in my case):

CODE:
  1. cd /etc/php5/fpm/pool.d/
  2. sudo mv www.conf www.conf.disabled
  3. sudo service php5-fpm restart