nginx config file which works great with Codeigniter 2.0

This config file works great on Ubuntu 10.04 LTS server with nginx 0.7.65. Other software includes php 5.3.2, Code Igniter 2.0. Performance-wise I was able to squeeze 12,000 requests per second on static files and ~250 req/s on dynamic PHP pages.

This is a copy-paste from Chris Gaunt’s github page with a change in server name.

server {
    listen 8080;
    server_name www.metak.com metak.com;
    access_log /home/metak/metak.com/logs/access.log;
    error_log /home/metak/metak.com/logs/error.log;
    root   /home/metak/metak.com/public_html;

    # If file is an asset, set expires and break
    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
        expires max;
        break;
    }

	# Serve the directory/file if it exists, else pass to CodeIgniter front controller
	location / {
		try_files $uri @codeigniter;
	}

	# Do not allow direct access to the CodeIgniter front controller
	location ~* ^/index.php {
		rewrite ^/index.php/?(.*)$ /$1 permanent;
	}

	# CodeIgniter Front Controller
	location @codeigniter {
		internal;
		root /home/metak/metak.com/public_html;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		include fastcgi_config;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME /home/metak/metak.com/public_html/index.php;
	}

	# If directly accessing a PHP file in the public dir other than index.php
	location ~* \.php$ {
		root /home/metak/metak.com/public_html;
		try_files $uri @codeigniter;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		include fastcgi_config;
		include fastcgi_params;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	}

}
Advertisements

Installing Ruby 1.8.5 on Ubuntu

Great how-to is located at http://www.rubywizards.com/viewtopic.php?pid=19 Here’s the copy of it:

* Bring up the terminal, login as system root, and create temporary directory to store downloaded files.
[~/] su
[~/] mkdir local
[~/] cd local

* Download official source distribution. This will create a file named ruby-1.8.5.tar.gz in your local directory.
[~/local] wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.5.tar.gz

* Extract all the files from downloaded archive. This will create local/ruby-1.8.5 subdirectory that stores extracted files.
[~/local] tar xvfz ruby-1.8.5.tar.gz

* Install GNU C++ compiler you’ll need to build Ruby from source.
[~/local] apt-get install build-essential

* Run configure utility to determine your system configuration.
[~/local] cd ruby-1.8.5
[~/local/ruby-1.8.5] ./configure

* Run make command to compile and build Ruby.
[~/local/ruby-1.8.5] make

* Test newly built Ruby executable by running regression test suite. Upon successfull completion you’ll see a message like: “Finished in 44.904424 seconds. 1440 tests, 13585 assertions, 0 failures, 0 errors.”
[~/local/ruby-1.8.5] make test-all

* Install Ruby onto your system. This will move Ruby executable and utilities to /usr/local/bin and standard Ruby libraries to /usr/local/lib/ruby.
[~/local/ruby-1.8.5] make install

* Install Ruby documentation. This will compile Ruby documentation in format required for ri command.
[~/local/ruby-1.8.5] make install-doc

At this point the installation of Ruby 1.8.5 is complete. If you had previous version of Ruby installed in /usr/local/bin, you should take two extra steps:

* Make sure /usr/local/bin comes before /usr/bin in your $PATH:
[~/local/ruby-1.8.5] echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games

* Logout from your current terminal session and login again to reload hashed value of ruby:
[~/local/ruby-1.8.5] which ruby
/usr/local/bin/ruby
[~/local/ruby-1.8.5] ruby -v
ruby 1.8.5 (2006-08-25) [i686-linux]

Mike Dvorkin, Ruby Wizards Admin
http://www.rubywizards.com

NetworkManager on Ubunty Edgy 6.10

I recently installed a Ubuntu 6.10 on USB stick.

Wireless worked like a charm. Network manager took some searching to do. So here it is

http://www.debianadmin.com/enable-wpa-wireless-access-point-in-ubuntu-linux.html

Apache’s ProxyPass on Ubuntu

  1. Install apache2. On Ubuntu type:
     # apt-get install apache2
  2. Activate mod_proxy:
     # a2enmod proxy
  3. Create a new file in /etc/apache2/sites-available, named metak (or whatever):
    NameVirtualHost *
    <Virtualhost *>
      DocumentRoot "/var/www/metak"
      ServerName localhost
      ServerAdmin support@mycompany.com
      DirectoryIndex index.html index.phpProxyRequests On
      ProxyPreserveHost On
      ProxyVia full
    
      <proxy>
        Order deny,allow
        Allow from all
      </proxy>
    
      ProxyPass        /  http://www.metak.com
      ProxyPassReverse /  http://www.metak.com
    </Virtualhost>
  4. Enable the new site and restart apache2:
    # a2ensite metak
    # /etc/init.d/apache2 reload

VMWare on Ubuntu 6.06

Great howto is located here:

http://www.ubuntuforums.org/showthread.php?t=183209

It worked as described right out of the “box”.

Logitech MX-500 on Ubuntu 6.06

  1. Open your /etc/X11/xorg.conf
  2. Comment out the “InputDevice” part for the mouse. Add these lines:
    Section "InputDevice"
    Identifier "Logitech MX500"
    Driver "mouse"
    Option "InputFashion" "Mouse"
    Option "Protocol" "ExplorerPS/2"
    Option "Buttons" "10"
    Option "ZAxisMapping" "4 5"
    Option "Device" "/dev/input/mice"
    Option "Resolution" "800"
    Option "CorePointer"
    Option "ButtonMapping" "1 2 3 6 7"
    EndSection
  3. In the “ServerLayout” section change the mouse line to
    InputDevice "Logitech MX500"
  4. Optionally, comment out “stylus”, “cursor” and “eraser”, as they refer to the tablet.
  5. Save the file. Press CTRL+ALT+Backspace to restart GNOME.