NginX, PHP, FastCGI

Posted by stoyan

Preparation

I added PHP to bbox512 nginx . For Debian/Ubuntu it needed FastCGI:

# apt-get install libfcgi0

RTFM

Installation

# cd /etc/default/
# wget -O php-fastcgi http://zhware.net/files/nginx/php-fastcgi.txt
# cd /etc/init.d/
# wget -O php-fastcgi http://zhware.net/files/nginx/php-fastcgi.rc.txt
# chmod 755 php-fastcgi
# cd /opt/nginx/conf/sites/
# wget -O static.conf http://zhware.net/files/nginx/sites/static.conf.txt
# /etc/init.d/php-fastcgi start
# kill -HUP `cat /opt/nginx/logs/nginx.pid`

In fact it’s just starting FastCGI PHP instances and making small changes to the sites/static.conf to process files with .php extension:

location ~ \.php$ {
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;
  fastcgi_param QUERY_STRING $query_string;
  fastcgi_param REQUEST_METHOD $request_method;
  fastcgi_param CONTENT_TYPE $content_type;
  fastcgi_param CONTENT_LENGTH $content_length;
}

Evented Mongrel and bbox2 blog

Posted by stoyan

On bbox2 i installed swiftiply gem . This changed the mongrel_rails command to use evented mongrel – mongrel, patched to use eventmachine tcp stack instead of the original pure ruby one. In /etc/init.d/mongrel_cluster i’m starting all mongrel instances with:
env EVENT=1 mongrel_cluster_ctl start ...
And because only testing is boring ;) I deployed restolog also to bbox2 . Now it’s available on both bbox and bbox2:

So now there is a “real world” application running on nginx+evented mongrel cluster. In fact the current post is done via bbox2 :)

The backend is the same database, so there will be no duplicated etc. posts.

I wanted to do the benchmarks again but ab seems buggy – it’s hang after sending 900 requests ( -c 100 -n 1000 ). Searching the internet gave me that: ab hang . Hm, maybe will try httperf.

BrightBox Hosting

Posted by stoyan

Thanks to Jeremy Jarvis i received a Brightbox beta account . I’m tring to blog about my experience on http://blog.bbox.selfip.net/ . Not sure how long I can keep that accounts, so maybe the blog will become unavailable soon. Still there was a good way to try the new Restolog version – multiuser, multiply blogs per user.

There was interesting benchmark – apache2, nginx and litespeed on the VPS account (256MB RAM):

All servers perform pretty much the same, but for VPS with not so much memory, Litespeed seems the best option.