Entries Tagged 'Linux' ↓
February 4th, 2012 — Linux, PHP
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:
-
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:
-
proxy_redirect off;
-
proxy_set_header Host $host;
-
proxy_set_header X-Real-IP $remote_addr;
-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
client_max_body_size 10m;
-
client_body_buffer_size 128k;
-
proxy_connect_timeout 90;
-
proxy_send_timeout 90;
-
proxy_read_timeout 90;
-
proxy_buffers 32 4k;
-
-
allow 192.168.1.0/24;
-
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:
-
server {
-
-
location /sabnzbd {
-
include /etc/nginx/conf.d/proxy.conf;
-
-
proxy_pass http://localhost:9090;
-
}
-
-
location /sickbeard {
-
include /etc/nginx/conf.d/proxy.conf;
-
-
proxy_pass http://localhost:8081;
-
}
-
-
location /couchpotato {
-
include /etc/nginx/conf.d/proxy.conf;
-
-
proxy_pass http://localhost:5000/;
-
rewrite ^/couchpotato/?$ /couchpotato/movie/ permanent;
-
}
-
-
location /spotweb {
-
alias /home/leon/src/spotweb/spotweb.git; #not root directive
-
-
location ~* \.php$ {
-
fastcgi_pass localhost:9001; #defined in /etc/php5/fpm/pool.d/leon.conf
-
include fastcgi_params;
-
fastcgi_index index.php;
-
}
-
}
-
-
}
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:
-
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:
-
; Start a new pool named 'leon'.
-
[leon]
-
listen = 127.0.0.1:9001
-
user = leon
-
group = leon
-
-
pm = dynamic
-
pm.start_servers = 1
-
pm.min_spare_servers = 1
-
pm.max_spare_servers = 4
-
pm.max_children = 4
Step 5: Restart everything and admire your work
CODE:
-
leon@panda:~$ sudo service nginx restart
-
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:
-
cd /etc/php5/fpm/pool.d/
-
sudo mv www.conf www.conf.disabled
-
sudo service php5-fpm restart
January 30th, 2012 — Linux
Easy as:
CODE:
-
/usr/bin/screen /dev/ttyUSB0 115200
December 24th, 2011 — Linux
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:
-
sudo ufw enable
-
sudo ufw default deny
-
sudo ufw deny "Dovecot POP3"
-
sudo ufw deny "Dovecot IMAP"
-
sudo ufw deny "Dovecot Secure IMAP"
-
sudo ufw deny "Dovecot Secure POP3"
-
sudo ufw status verbose
December 9th, 2011 — Linux
CODE:
-
# tar -ztvf babyhuiscasita.nl.tar.gz |grep sql
-
# tar -xzvf babyhuiscasita.nl.tar.gz ./.backup/babyhuiscasita.nl_mysql
-t = list
-x = extract
November 23rd, 2011 — Linux
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:
-
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to:
CODE:
-
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!
November 9th, 2011 — Linux
To route an ip address through a (vpn) connection:
CODE:
-
sudo route add -net XX.192.85.XX netmask 255.255.255.255 gw 192.168.1.1
-
sudo route add -net 10.76.122.0 netmask 255.255.255.0 gw 192.168.1.1
-
route -n
October 26th, 2011 — development, Linux, PHP, python, Ruby
I installed sublime text on my Ubuntu 11.10 box but I had some troubled loading external python modules:
CODE:
-
loaded 937 snippets
-
>>> import distutils
-
Traceback (most recent call last):
-
File "<string>", line 1, in <module>
-
ImportError: No module named distutils
This is how I solved it:
Edited ~/.local/share/applications/sublime.desktop
Especially this line:
CODE:
-
Exec="/home/leon/Software/bin/sublime" %U
/home/leon/Software/bin/sublime contains this:
CODE:
-
#!/bin/bash
-
cd /usr/lib/python2.7
-
/home/leon/Software/SublimeText2/sublime_text
Then I installed some excellent plugins:
October 24th, 2011 — Linux
Copy the mono paste icon over to ~/.icons/Humanity/actions/22/edit-paste.svg
September 14th, 2011 — Linux
Something to never forget again:
CODE:
-
rsync --recursive me@remote:'"~/Very complicated path/"' ~/Downloads/
So: single quote, double quote, path, double quote, single quote
September 6th, 2011 — Linux, PHP
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:
-
sudo apt-get install libc6-i386 ia32-libs
-
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