Entries Tagged 'Linux' ↓

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

Access a pandboard with a ‘screen’ serial console

Easy as:

CODE:
  1. /usr/bin/screen /dev/ttyUSB0 115200

Ubuntu 11.10 on my laptop and ufw

I decided on enabling ufw (uncomplicated firewall) on my laptop (you can't be secure enough). Too bad it isn't enabled by default on Ubuntu. So I had to do this:

CODE:
  1. sudo ufw enable
  2. sudo ufw default deny
  3. sudo ufw deny "Dovecot POP3"
  4. sudo ufw deny "Dovecot IMAP"
  5. sudo ufw deny "Dovecot Secure IMAP"
  6. sudo ufw deny "Dovecot Secure POP3"
  7. sudo ufw status verbose

Listing contents of a tar.gz and extracting one specific directory

CODE:
  1. # tar -ztvf babyhuiscasita.nl.tar.gz |grep sql
  2. # tar -xzvf babyhuiscasita.nl.tar.gz ./.backup/babyhuiscasita.nl_mysql

-t = list
-x = extract

Asus k53sv & ubuntu power management

Using my new Asus k53sv with Ubuntu 11.10 resulted in 2 hours of battery time. I know the k53 doesn't have a fancy battery (quite the opposite) but I thought 2 hours was really bad.

With the power regression bug of the Linux kernel in my mind, I started searching. A lot of posts suggested using "pcie_aspm=force". I tried that by editing the grub menu, but that didn't really help (at all). dmesg kept complaining about the bios not letting it so that was a dead end.

Phoronix suggested enabling some power options for the i915 chipset (onboard videocard).

So I changed the following in /etc/default/grub:

CODE:
  1. GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to:

CODE:
  1. GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pcie_aspm=force i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 i915.lvds_downclock=1"

After a reboot the remaining battery time had changed from 2 hours to a little less than 3 hours. That's an improvement of almost 50%!

The only downside was that after a suspend (to memory) the screen gets garbled. But after a ctrl+F1 and ctrl+F8 that's fixed. So I'm actually quite happy know. Thanks Phoronix!

3 useful route commands

To route an ip address through a (vpn) connection:

CODE:
  1. sudo route add -net XX.192.85.XX netmask 255.255.255.255 gw 192.168.1.1
  2. sudo route add -net 10.76.122.0 netmask 255.255.255.0 gw 192.168.1.1
  3. route -n

Sublime Text 2

I installed sublime text on my Ubuntu 11.10 box but I had some troubled loading external python modules:

CODE:
  1. loaded 937 snippets
  2. >>> import distutils
  3. Traceback (most recent call last):
  4.   File "<string>", line 1, in <module>
  5. ImportError: No module named distutils

This is how I solved it:

Edited ~/.local/share/applications/sublime.desktop
Especially this line:

CODE:
  1. Exec="/home/leon/Software/bin/sublime" %U

/home/leon/Software/bin/sublime contains this:

CODE:
  1. #!/bin/bash
  2. cd /usr/lib/python2.7
  3. /home/leon/Software/SublimeText2/sublime_text

Then I installed some excellent plugins:

Chaning the glippy indicator icon

Copy the mono paste icon over to ~/.icons/Humanity/actions/22/edit-paste.svg

 

Using rsync with spaces

Something to never forget again:

CODE:
  1. rsync --recursive me@remote:'"~/Very complicated path/"' ~/Downloads/

So: single quote, double quote, path, double quote, single quote

The continuing story of Zend Studio 5.5.1

Everytime I install a new version of Ubuntu / Linux I'm hoping Zend Studio (the old/good one) will still be working. So I installed Ubuntu 11.10 and also this time I had to install some stuff to get Zend Studio working.

CODE:
  1. sudo apt-get install libc6-i386 ia32-libs
  2. ln -s /lib32/libc.so.6 /lib/libc.so.6

And it worked! Know I'm gonna try do update the JRE of the Zend Studio 5.5