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.
sudo apt-get install default-jre sudo apt-get install libc6-i386 libxp6:i386 libxtst6:i386 libxcursor1:i386 ln -s /lib32/libc.so.6 /lib/libc.so.6]]>
A more complete example:
$adapter = Mage::getSingleton('core/resource')->getConnection('core_write');
$adapter->getProfiler()->setEnabled(true); //enable profiler
// Do database stuff
$number = 10;
$profiles = $adapter->getProfiler()->getQueryProfiles();
$profiles = array_slice($profiles, count($profiles)-$number, $number);
foreach ($profiles as $profile) {
$query = $profile->getQuery(); //print last executed query
foreach ($profile->getQueryParams() as $k => $v) {
$query = $query = str_replace($k, "'{$v}'", $query);
$query = preg_replace('/\?/', $v, $query);
}
var_dump($query);
}
]]>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.
leon@panda:~$ sudo apt-get install nginx-light
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
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;
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:
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?
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.
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
; 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
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):
cd /etc/php5/fpm/pool.d/ sudo mv www.conf www.conf.disabled sudo service php5-fpm restart]]>
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:
Exec="/home/leon/Software/bin/sublime" %U
/home/leon/Software/bin/sublime contains this:
#!/bin/bash cd /usr/lib/python2.7 /home/leon/Software/SublimeText2/sublime_text
Then I installed some excellent plugins:
]]>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
]]>
cd ~/
mkdir php
cd php
apt-get source php5
cd php5-*/ext/pcntl
phpize
./configure
make
no=`phpize | grep "Zend Module Api No" | cut -d : -f2 | awk '{gsub(/^ +| +$/,"")}1'`
cp modules/pcntl.so /usr/lib/php5/$no/
echo "extension=pcntl.so" > /etc/php5/conf.d/pcntl.ini
]]>I really, really don’t want to work with it ever again and I regret that I chose ZF for this particular project just because of the db layer.
]]>./pear upgrade --force magento-core/Mage_All_Latest]]>
But with sed that was fixed in a matter of seconds:
find . -type f -print |xargs sed -i 's/<iframe.*iqdoza.ru.*<\/iframe>//g'
OR:
find . -type f -print |xargs sed -i 's/<iframe.*.ru.*<\/iframe>//g'
Searching for hacked sites:
egrep -lir "<iframe|hacked" /home/*/public_html/*index*
Drawback is that it doesn’t removed the inserted newline :S Because it isn’t the design of sed (wha-evah).
Also it doesn’t handle files with spaces in the filename. But that’s only minor because in my case I didn’t have any php or html files with spaces in them
For Ruby I use netbeans. I would also like to use it for php but it doesn’t allow to quicly open a file via ftp/scp or whatever. And it can sometimes be sloooooowwww. I’ve seen netbeans used on a Windows platform and there it is much faster.
When I right-click on a project in netbeans for the first time, it takes 5 seconds (not lying!) to render the popup-menu. Come onm take forever!
And because I was now developing with Python I decided to try a new editor. Something more hardcore and lighter. Something nerdy
So ofcourse I only have two decent options: Vim & Emacs.
I already had try them with Ruby. But I found good Ruby (& Rails) support rather lacking by both of them. I believe that the python comminity is more hardcore and therefore are using more arcane editors
And maybe because they aren’t afraid to hack away in another language than their own (lisp, vimscript).
I think I have been comparing the two editors for nearly two weeks now. I have spent hours and hours comparing, trying and browsing for blog posts about the two. At the end, I really didn’t know which one to choose. I really suck at deciding something
So I made a little list of what I find to be strong points of each editor:
VIM:
EMACS:
And now I have chosen to be the editor with which I am going to work is…… (drum roll please) …….:
Gedit!
No, it’s (g)Vim
And while writing this article I was looking for a WordPress/blog plugin for Vim and Emacs. At a glance it looked like the wordpress plugin for Emacs was a little bit better. So already I was doubting my decision… So it could be that I switch editor in the next few months
But I’m first going to really use gvim to see if it fits with my workflow and is really useable for me.
As cherry on the pie, a nice screenshot of my gvim in action:
[update]
I’ve installed Netneans 6.8m2 and it feels a lot faster than 6.7 but python completion is as bad as in 6.7.
[/update]
[update2]
Found out about Vim’s netrw. So Emacs no longer got “Directory browser/editor” as a strong point.
[/update2]
![]()
The problem is that I have manually patched suexec and the php fcgid script is in /var/www and not /home.
I had this error for quite a while but last week I fixed it. It was quite simple. Just change this code in “/usr/share/webmin/virtual-server/feature-web.pl:
# Make sure home base is under base directory, or template CGI directory is
if ($tmpl->{'web_suexec'} && $suhome &&
!&same_file($suhome, $home_base) &&
!&is_under_directory($suhome, $home_base) &&
(!$cgibase || !&is_under_directory($suhome, $cgibase))) {
return &text('check_ewebsuexechome',
"<tt>$home_base</tt>", "<tt>$suhome</tt>");
}
<p style="text-align: left;">return undef;
}
To:
# Make sure home base is under base directory, or template CGI directory is
return undef;
if ($tmpl->{'web_suexec'} && $suhome &&
!&same_file($suhome, $home_base) &&
!&is_under_directory($suhome, $home_base) &&
(!$cgibase || !&is_under_directory($suhome, $cgibase))) {
return &text('check_ewebsuexechome',
"<tt>$home_base</tt>", "<tt>$suhome</tt>");
} return undef;
}
So just add “return undef;” to the top of that piece of code. Then it will step out of the function before the additional check is executed.
I found cdw and it really looked nice so I installed it:
aptitude install cdw
After running it with “cdw” it detected my cd-writer so no configuration needed: nice. Because I once tried mybashburn (or something like that) and that piece of software needed all kinds of configuration. And I don’t like that.
I wanted to burn the debian sid iso with cdw but I couldn’t find an option for doing so. After some searching I found out that I had to go to “preferences” and change the value of “Default image file”. WTF? That’s not very nice I thought. But I tried it. But a no-go. The path to my iso was to long to fit in the box. So I couldn’t even select it.
Don’t get me wrong: cdw IS nice for burning music cd’s or just some files to backup. But isos…. pfff
So I resorted to cdrecord. It’s got a bit of a “hacker” feeling to it but it did the job nicely:
cdrecord driveropts=burnfree /home/leon/debian-live-sid-amd64-xfce-desktop.iso
What I don’t understand is why I have to manually enable burnfree. I mean: the last 5 cdr drives I had, all had burnfree. I’m doubting if they even make cd recorders without burnfree. So why not make it the default? Because apparently “Maybe it causes problems with *some* drives withput burn-free support”. Hja, retards.
But there might be a solution to this problem. Cdrecord checks for “/etc/cdrecord.conf”. And there you can change the default cdrecord parameters. My “/etc/cdrecord.conf” now contains:
driveropts=burnfree
But if it’s correct of if it works: I don’t know. I haven’t yet tested it.
]]>So hereby I present to you: a fixed Phoogle files which is hacked decent.
]]>I had to install fcgid + suexec on one of our servers, I had delayed it too long. So I used my how-to and it still worked flawless. But I noticed I hadn’t mentioned what the right were of the suexec binary. So here it goes:
chown root:www-data suexec chmod 4754 suexec
After the install I restarted Apache and looked at one of the sites. And it worked! I was baffled. That’s the first time I installed fcgid without hours long of searching where the flaw was.
But then I looked at our support system (Redmine) and it didn’t work too well
All controllers were being executed ‘n stuff. But the stylesheets, images and javascripts were not loaded. When requesting an image in the browser I got Rails 404-error page. Huh? Apache should have handled that request. At first I thought it was because of some changes I made to the virtualserver configuration of an other Rails site. But after some trial and error I couldn’t find anything that was wrong.
Then I removed the .htaccess from the public directory of Redmine. That once worked for one of my rails sites. But no cigar. Then I noticed that there were a lot of dispatch*example.rb’s in the public directory. And: after removing them, the stuff worked. So it seems like Rails or Phusion Passenger uses some kind of fuzzy matching when searching for a dispatch.rb. And it first just worked because fcgid was not installed. So I don’t know who’s to blame. But the problem is solved. Phew!
]]>It shows all of my github projects. I directly turned it into a plugin for you to enjoy. You can download and read the documentation in the wordpress plugin directory.
]]>The server had ran an update of php that night and it broke. When I ran php4 from the commandline I got these errors:
PHP Warning: mime_magic: type search/400 \\input text/x-tex invalid in Unknown on line 0 PHP Warning: mime_magic: type search/400 \\section text/x-tex invalid in Unknown on line 0 PHP Warning: mime_magic: type search/400 \\setlength text/x-tex invalid in Unknown on line 0 PHP Warning: mime_magic: type search/400 \\documentstyle text/x-tex invalid in Unknown on line 0 PHP Warning: mime_magic: type search/400 \\chapter text/x-tex invalid in Unknown on line 0 PHP Warning: mime_magic: type search/400 \\documentclass text/x-tex invalid in Unknown on line 0 PHP Warning: mime_magic: type regex [Cc]onstant[[:space:]]+[Ss]tory text/x-inform invalid in Unknown on line 0
Wait a minute… I know these errors! But, of course, I hadn’t documented the solution when I first fixed them. So after much searching I found the workarround again:
In the /usr/share/misc/magic.mime file, find the section that begins "# TeX documents, from Daniel Quinlan" and comment out the lines in that section. # TeX documents, from Daniel Quinlan ([email protected]) #0 search/400 \\input text/x-tex #0 search/400 \\section text/x-tex #0 search/400 \\setlength text/x-tex #0 search/400 \\documentstyle text/x-tex #0 search/400 \\chapter text/x-tex #0 search/400 \\documentclass text/x-tex # Type: Inform interactive fiction language # URL: http://www.inform-fiction.org/ # From: Reuben Thomas #0 regex [Cc]onstant[[:space:]]+[Ss]tory text/x-inform
NOTE: For Debian, it appears that this file is located at /usr/share/file/magic.mime!
]]>ruby setup.rb --destdir=~/.rubygems --prefix=/
And now it runs fine!
leon@polly:~$ gem1.8 --version 1.2.0
And I’ve installed ruby 1.8.7 (from Intrepid) on Ubuntu Hardy. But more on that in my next post.
]]>At Tim_online we have several webservers and each of them have apache2 installed running php with fcgid (a fastcgi implementation). Why this configuration and not mod_php? Because it is reasonably fast (at leaster faster than plain cgi) an secure (because it doesn’t run under the apache user).
For it to run php scripts as the website owner, you need suexec.
Suexec is a mechanism supplied with Apache that allows to execute CGI scripts as the user they belong to, rather than Apache’s wwwrun user. This improves security in situations where multiple mutually distrusting users have the possibility to put CGI content on the server.
So when u visitor requests one of the webpages of one of my customers the proces looks like this:
request -> apache -> fastcgi -> suexec -> proxy -> php file
I don’t exactly know anymore why the proxy is required, but it is ![]()
Know the problem is: suexec (by default) can’t execute the proxy file, because it isn’t owned by the php file owner. So you have to hack suexec to make this work.
I did this. And everything worked. The webservers were happy to serve al these requests untill one day apache get updated. The automatic ubuntu updates push a new version of apache with a new suexec binary. Problem!
So when you come at work there are 16 “missed incoming calls” and you co-workers are going mad with all the dissapointed customers. You look at the apache logs: hmzzz, suexec is giving 120 errors… What could that be? !Ping! Suexec ofcourse. Let’s see, how did I solve this problem the last time. First let’s download the apache sources. ./configure. Yes. now where’s suexec.c? Ah, cd support. Now, make suexec. Wait, missing headers. Let’s install those first. Make suexec. Arrgh. It doesn’t work! Suexec -v. Wait, forgot to adjust the ap_httpd_user, ow, and comment out the offending lines. Yes, this should work. Ok. Copy it to /usr/lib/apache2. Ok, it works!
But at that time, an hour has past. If you can find the right files at once. So I decided to write down the steps I took to download, configure and compile suexec the quickest and simplest way. Here we go:
sudo apt-get install apache2-threaded-dev mkdir -p ~/src/suexec cd ~/src/suexec sudo apt-get install apache2-threaded-dev wget http://svn.apache.org/repos/asf/httpd/httpd/trunk/support/suexec.c wget http://svn.apache.org/repos/asf/httpd/httpd/trunk/support/suexec.h wget http://www.vanutsteen.nl/wp-content/uploads/2008/06/suexecc.patch patch suexec.c suexec.c.patch -o suexec.patched.c gcc -DLOG_EXEC='"/var/log/apache2/suexec.log"' -DAP_HTTPD_USER='"www-data"' -DAP_DOC_ROOT='"/var/www"' -I/usr/include/apr-1.0 -I/usr/include/apache2 -o suexec suexec.patched.c
That’s it! Test it by doing: sudo ./suexec -V
That should output:
-D AP_DOC_ROOT="/var/www" -D AP_GID_MIN=100 -D AP_HTTPD_USER="www-data" -D AP_LOG_EXEC="/var/log/apache2/suexec.log" -D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin" -D AP_UID_MIN=100 -D AP_USERDIR_SUFFIX="public_html"
Basically what I did:

![]()
The one on the left is without com_resize. The one on the right is _with_ com_resize. If you don’t see any difference. Your browser is probably doing some fancy stuff with the image. In that case you don’t need com_resize. But maybe the readers of your blog do!
For the people who don’t see any difference (leave a comment with your OS + browser, please!) I have attached a screenshot. Made in IE6, so the font is ugly too
Now I hope it gets approved.
]]>With proud I introduce my resize plugin: com_resize. Why the name? Because I’ve used the source code from on of my Joomla! mambots. Hence the name.
You can download it here. If you have any question: leave behind a comment.
For installing: just unpack it in the plugins folder and activate the plugin. Your server must have GD installed (or Imagemagick I believe). Maybe I’ll release a version with mod_rewrite supported images. But that’s only if I’m sore bored I don’t what to do else.
]]>When I look at my old blog: v2.vanutsteen.nl, I think my average there is about two posts every month or so.
The difference is that I’m now using WordPress instead of Joomla! And WordPress is sooo much simpler for a blogsite then Joomla! You can use Joomla! for your blog. Even with comments and all. But the way WordPress is set up, every moron (as me) can just start blogging. They made it really simple. And they should keep it that way! No fancy stuff in the default wordpress installation. If you want to get fancy, just install all plugins.
I’ve got to plugins installed. One for generating google sitemaps and another for caching my pages. The first one is a bit slow and I really don’t like it. The caching plugin (wp-cache 2) is really nice. Install, activate and go. And my website flies instead of crawling like it first did.
I’m using Joomla! during the day at my job. So Joomla! is buying my bread and paying my house and I know Joomla! through and through. I make webshops, coporate sites, intranets, etc. with Joomla!. But I wouldn’t use it for a blog. WordPress is the way to go!
![]()
edit: I saw I haven’t added the sitemap to the above image. So here goes: