Reference: http://www.travisglines.com/web-coding/how-to-set-up-apache-to-serve-html5-websocket-applications-with-pywebsocket
Environment: SuSE Linux entiprise Server 11 SP1 + apache2.2.19 + python2.6
For Apache installation, refer to my log: http://blog.csdn.net/fm0517/article/details/7299144
Start:
1. Confirm in YaST that the apache2-mod_python is installed, if not, install it:
Computer-> YaST-> software management-> Search-> enter "apache2-mod_python" in the search box, find the check box on the right to hook up.
2. Modify the Apache configuration file:
Open/usr/local/apache2/CONF/httpd. conf;
Find the content under "Options indexes followsymlinks ".
"AllowOverride none
Order allow, deny
Allow from all
"
Add the following content later
"Loadmodule python_module/usr/lib/apache2/mod_python.so
Addhandler mod_python. py
Pythonhandler mod_python.publisher
PythonDebug On
"
3. Restart apache
Run:/usr/local/apache2/bin/apache restart.
So far, the apache2-mod_python module has been installed and configured.
In the/usr/local/apache2/htdocs directory, edit the file test. py and enter the following content:
"From mod_python import apache
Def index (req ):
Return "Test successful"
"
Run in the browser and "Test successful" indicates that all previous steps are successful.
4. Install svn
To add the installation source, run the following command on the terminal:
Zypper ar http://download.opensuse.org/distribution/11.3/repo/oss/ main
Zypper ar http://download.opensuse.org/distribution/11.3/repo/non-oss/ nonoss
Zypper ar http://download.opensuse.org/update/11.3/ update
Install libapr1, libapr1-devel, libapr-util1, libapr-util1, subversion, subversion in sequence in Yast, and install the apache2-mod_python in the same way as step 1.
5. Check and install pywebsocket
Run the following command in the user's home directory to check out pywebsocket.
SVN checkout http://pywebsocket.googlecode.com/svn/trunk/ pywebsocket-read-only
Go to the pywebsocket-read-only/src directory and execute the following statements to compile and install the SDK:
Sudo Python setup. py build
Sudo Python setup. py install
6. Modify the Apache configuration file again:
Open/usr/local/apache2/CONF/httpd. conf;
Add the following content at the end of the file
"Pythonpath" SYS. Path + ['/usr/local/lib/python2.6/Site-packages/mod_pywebsocket']"
Pythonoption mod_pywebsocket.handler_root/home/ngxy/Apache-pywebsocket/websock_handlers
Pythonheaderparserhandler mod_pywebsocket.headerparserhandler
"
The first path is the installation path of mod_pywebsocket, which is displayed on the screen when "sudo Python setup. py install" is executed in step 5.
The second path is a directory manually created for websocket_handler. I created the directory in the user's main directory.
The two paths in the configuration file must be specified according to the actual situation and cannot be copied.
So far, the entire process of setting up pywebsocket on Apache to provide HTML5 websocket service has been completed.