I am currently running a VPS as a playground and my SVN repo and decided to go ahead and set up a websockets server as well. This proved to be a little tricky but eventually got it working. Note that installing the default mod_python will give you version 3.2.8. pywebsocket requires Python 2.3 and up and mod_python 3.3 and up. Heres how I set up my server:
Start off by enabling EPEL if you haven’t done so already:
rpm -ivh http://mirrors.kernel.org/fedora-epel/5/i386/epel-release-5-4.noarch.rpm
Next, install Python 2.6
yum install python26
Then install mod_python 2.6
yum install python26-mod_python
I chose to run it under apache so next you need to edit your httpd.conf file.
LoadModule python_module modules/python26-mod_python.so
LoadModule python_module libexec/apache2/python26-mod_python.so
AddHandler mod_python .py
Please note the path to Python as well as the PythonOption path. I put my websock handlers in the var folder but you can put it anywhere just make sure to create the document root for those websocket handlers.
After this you can restart your server:
/etc/init.d/httpd restart
Once restarted you can then download the pywebsocket repository
cd
svn checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only
Then install:
cd pywebsocket-read-only
cd src
python setup.py build
sudo python setup.py install
Next you will need to also add this to httpd.conf:
PythonPath "sys.path+['/usr/lib/python2.6/site-packages']"
PythonOption mod_pywebsocket.handler_root /var/websock_handlers
PythonHeaderParserHandler mod_pywebsocket.headerparserhandler
PythonOption mod_pywebsocket.allow_draft75 On
Then all you have to do is restart apache, create the repository from above (in my example it is /var/websock_handlers). Then cp over echo_wsh.py from the /src/examples directory. Finally all you need to run is ./echo_client.py and you should receive some output similar to:
Send: Hello
Recv: Hello
Send: 日本
Recv: 日本
Send: Goodbye
Recv: Goodbye