Mongrel2
The Language Agnostic Web Server
Not logged in
Why donate?

Getting Started With Mongrel2

Translations: .ru .de .es

This is the fastest way to get started with Mongrel2. Nothing is really explained, just all the stuff you need is setup and you get to run a few commands. If you want very good explanations for all of this, go read The Mongrel2 Manual (HTML) a complete manual covering everything from getting started, to writing your first handlers.

This getting started assumes you know what you're doing and can run commands in Unix.

Building The Dependencies

Here's how I might do it on ArchLinux:

# install ZeroMQ 
wget http://www.zeromq.org/local--files/area:download/zeromq-2.0.8.tar.gz 
tar -xzvf zeromq-2.0.8.tar.gz 
cd zeromq-2.0.8/ 
./configure 
make 
sudo make install 
 
# install python 
sudo pacman -S python 
 
# install sqlite3 
sudo pacman -S sqlite3 
 
# install distribute and pip 
sudo pacman -S python-pip 
sudo pip install distribute 
 
# install PyZMQ from github 
sudo pacman -S git 
git clone http://github.com/zeromq/pyzmq.git 
cd pyzmq
sudo python setup.py install 
 
# web.py 
sudo pip install web.py

Getting The Source

Quickest way to do that is to grab the tar.bz2 file:

wget http://mongrel2.org/static/downloads/mongrel2-1.0beta7.tar.bz2

Building Mongrel2

Now you need to build mongrel2:

tar -xjvf mongrel2-1.0beta7.tar.bz2
cd mongrel2_2010-08-17_011326_58fb817f8e/
make clean all install

The version number for your directory might be different since we update it frequently.

Configuring The First Time

Now you can try out the simplest config example and get it running:

cp examples/python/tests/sample_conf.py myconfig.py
m2sh init -db myconfig.sqlite
m2sh load -db myconfig.sqlite  -config myconfig.py

NOTE:There's also examples/python/tests/mongrel2_org.py which is a more complete example.

Running Mongrel2

Now you can run this and try it. Make sure you're still in the mongrel2 source directory:

mkdir run logs tmp
m2sh start -db myconfig.sqlite -host localhost

From another window do:

curl http://localhost:6767/tests/sample.html
hi there

Shutting Down

Just do CTRL-C and it'll exit. m2sh has many other commands and some of them shut things down or restart. Run m2sh help to find out more.

Learn More From The Manual

That is the fastest crash course you can get in running Mongrel2. You should now go read The Mongrel2 Manual (HTML) which we took much more time writing and making very nice for you.