sophie is my oldest VPS, she's a Rackspace VPS with 512M RAM. When i first got sophie somewhere in 2008 I installed Apache 2 with mod_php as was the fashion at the time.

Times have changed since then - webservers have evolved and running Apache isn't the coolest thing anymore.

Somewhere in 2009 I got my eyes on lighttpd and set it up to work with php via FCGI, running Apache in parallel on port 81 and doing proxy passes from lighttpd for those domains that required URL rewriting.

My reason for keeping Apache on the machine was pure lazyness. I didn't want to and didn't know really how to translate rewrite rules between Apache and lighttpd.

Frustrated over my server's constant memory shortage in 2012 I decided that ther can only be one. Subsequently I moved everything to Apache.

Running only Apache sped some things up but using Apache for all my domains put the memory usage at nearly where it was when I had both lighttpd and Apache.

I decided that moving everything to Apache was a bad idea and cursed my lazyness.

Yesterday evening I moved everything to nginx, even the URL rewriting works!

I use php-fpm for PHP FCGI, and have it set up at localhost:9000.

This is my configuration for YOURLS at http://wndb.org.

  1. server {
  2. listen 80;
  3. root /path/to/yourls;
  4. index index.php;
  5. server_name wndb.org;
  6. location ~ \.php$ {
  7. include fastcgi_params;
  8. fastcgi_pass 127.0.0.1:9000;
  9. fastcgi_index index.php;
  10. }
  11. location / {
  12. try_files $uri $uri/ @yourls;
  13. }
  14. location @yourls {
  15. rewrite ^(.*)$ /yourls-loader.php;
  16. }
  17. }

This is the configuration for my StatusNet instance at http://status.wandborg.se.

  1. server {
  2. listen 80;
  3. server_name status.wandborg.se;
  4. root /var/www/statusnet/mainline;
  5. index index.php;
  6. location ~ \.php {
  7. include fastcgi_params;
  8. fastcgi_pass 127.0.0.1:9000;
  9. fastcgi_index index.php;
  10. }
  11. location / {
  12. try_files $uri $uri/ @statusnet;
  13. }
  14. location @statusnet {
  15. rewrite ^(.*)$ /index.php?p=$1 last;
  16. }
  17. }

Which was heavily inspired by Installing laconi.ca on nginx by Maxime Pelletier.

That's it, that's all.