Skip to content

Installing a debian Morzo server from scratch

tdammers edited this page Feb 17, 2013 · 10 revisions

Step 1: Install debian

  • Download the debian stable i386 netinst iso. Suitable jigdo, bittorrent and http download links can be found at http://www.debian.org/CD/.
  • Boot from the netinst iso and install a minimal core system: check only the "SSH Server" and "Basic System Utilities" presets. We'll install all the dependencies in the next step.
  • Set up ssh and networking to your preferences. I like to give my virtual servers two network interfaces: NAT on eth0 (to be used to access the internet from the virtual machine, for things like API calls and apt), and host-only on eth1 (to be used to ssh into the machine and serve web pages). This way, the VM can make outbound connections as needed, but will be naturally firewalled off of the real world for incoming connections.
  • Install your favorite text editor. I use vim.

You should now be able to boot the server, ssh into it, and become root in order to install things.

Step 2: Install required packages

We'll need to install a whole bunch of packages, so let's get started:

$ sudo aptitude install apache2 php5 php5-cli libapache2-mod-php5 \
php5-xdebug \
php5-adodb libphp-adodb \
php5-mysql mysql-client mysql-server \
memcached php5-memcache ntp \
php5-gmp

Aptitude tells me there's one conflict; the first resolution it offers should work fine.

Step 3: Pull in the code.

There are two ways you can do this: either install git inside the VM and use that, or set up a shared directory between the VM and the host machine. I opted for the latter, mounting a directory on the VM into a sshfs mount on the host. The procedure is something like this:

tobias@host$ mkdir morzo
tobias@host$ ssh morzovm
tobias@morzovm$ mkdir morzo
tobias@morzovm$ exit
tobias@host$ sshfs tobias@morzovm:morzo morzo
tobias@host$ cd morzo
tobias@host$ git clone ssh://[email protected]/trezker/morzo .
...
tobias@host$ ssh morzovm
tobias@morzovm$ cd morzo
tobias@morzovm$ ls
blocked.php                database_structure.sql  models          sql_backup.sh
config.rep.php             docroot                 README          sync.sh
controllers                libraries               run_update.php  util
database_initial_data.sql  logs                    run_update.sh   views

Step 4: Download and install php-openid

From the morzo project root:

  • $ git clone https://github.com/openid/php-openid.git php-openid
  • $ cp -R php-openid/Auth docroot/Auth
  • $ sudo chgrp -R www-data docroot/Auth
  • $ mkdir oid_store
  • $ sudo chgrp www-data oid_store
  • $ chmod 770 oid_store

Step 5: Configure Apache

  • Become root (sudo -i or su -).
  • $ cd /etc/apache2/sites-available
  • $ cp /home/yourname/morzo/apache-config morzo
  • Now edit morzo to point the document root to the docroot directory inside the morzo project directory; in my case, this is /home/tobias/morzo/docroot.
  • $ a2ensite morzo
  • $ a2dissite default
  • $ a2enmod rewrite
  • $ service apache restart
  • Now visit your VM in a browser. If you get a white page, check the apache error log (/var/log/apache2/error.log).

Step 6: Create and setup database.

  • Log into mysql as root: $ mysql -uroot -p
  • mysql> create database morzo;
  • mysql> use morzo;
  • mysql> grant select, update, insert, delete on * to morzo@localhost;

In order to get the game going, we'll also need to create at least one location:

  • `mysql> insert into Inventory (ID) values (1);
  • `mysql> insert into Location (ID, X, Y, Inventory_ID) values (1, 0, 0, 1);

Step 7: Test your setup.

  • Run the run_update.sh script in the project root. This script performs one time-tick in the game universe; for development purposes, you can run it manually, but on a production or staging server, this should be driven from a cron job. You need to run it at least once in order to create a few suitable actors for your first account.
  • Fire up a web browser and visit your new server's home page (http://yourserver/). Log in with OpenID, create an account, and then spawn an actor.

That's it, you should be good to go.