Setting Up a Development Server
These are the steps I needed to take (and didn't need to take, but that you will need to on other platforms) to set up a development server on a new MacBook? on 2008-08-27.
You need to be familiar with Terminal, and you'll be using the sudo command to do things as root. If these things sound frightening you should start by googling around a little.
- Install XCode Tools. You're going to need XCode so that you can build the Python/MySQL adapter and the PyCrypto? library later. You can download XCode from http://developer.apple.com/tools/xcode/. It's free, but it's a big download. While you're downloading it, move onto the next couple of steps.
- Python 2.5 is already installed on Mac OS X 10.5. Rejoice.
- easy_install is already installed on Mac OS X 10.5. Aren't you glad you bought a Mac?
- Install a MySQL database server. It's free and open-source. http://dev.mysql.com
- Add the MySQL server binaries to your path. To do this you need to create a bash profile.
$ emacs ~/.bash_profile
Then, put this in the new file you've just created in EMACS:
export PATH=$PATH:/usr/local/mysql/bin
Then save and close your new profile by pressing CTRL-X, CTRL-S, CTRL-X, CTRL-C. Then to make use of your new profile, close and re-open your terminal.
- So long as the previous step went well you should now be able to start up your MySQL server by typing:
$ sudo safe_mysqld
If that fails to work, you didn't manage to reconfigure your path properly. Google for help.
- Install web.py
$ sudo easy_install web.py
- Install Python Crypto
$ sudo easy_install pycrypto
Installing PyCrypto? under Windows is not so trivial. You will need to install MinGW, then perform the install manually (or tweak the easy_install configuration). This page summarises how to get the job done quickly.
- In order to run the administration interface, install Django. http://www.djangoproject.com/download/
- Build a Python/MySQL adapter. Download the tarball from http://sourceforge.net/projects/mysql-python. Then untar it, patch _mysql.c by hand and install. Sounds hard? It is. Hopefully by the time you come to do this, installing the mysql adapter will be as easy as sudo easy_install mysql_python. See http://forums.mysql.com/read.php?50,175059,219216#msg-219216 for more info.
$ tar -xvf MySQL-python-1.2.2.tar $ cd MySQL-python-1.2.2 $ emacs _mysql.c (... and patch as shown on teh internets -- you need to comment out lines 37-39) $ sudo python setup.py install $ sudo mkdir /usr/local/mysql/lib/mysql $ sudo cp /usr/local/mysql/lib/libmysqlclient_r.15.dylib /usr/local/mysql/lib/mysql/libmysqlclient_r.15.dylib
Hilariously, on Windows, this step is much easier. Just get the binary installer from Sourceforge: http://sourceforge.net/projects/mysql-python
You've now finished installing all of the required software. Next you need to set up the initial data and permissions in the database.
- Download CocoaMySQL, or an alternative MySQL client of your choosing.
- Log into your own MySQL server as root.
- Create a database called "xts".
- Import a database backup from Maude. It's the fastest way to get up and running with plenty of real-world data.
- Set permissions so that the anonymous user on localhost ("@localhost") has full access to the xts database. These are very lax permissions, but they'll do for a development server.
- Finally, run the XTS server. In whatever directory you have a copy of the XTS source, run:
$ python server.py
You can now visit http://localhost:8080 in a web browser on your own computer to play around. So long as the version signature under the XTS logo shows "DEV", you're looking at your own server.
- Get hacking.
