Build pywebsocket on Apache to provide html5 websocket Service

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.