您的位置:首页 > 运维架构 > Apache

OpenSuse11.4+Apache+Django搭建Webserver

2013-08-19 00:00 232 查看
1.Install Django

https://www.djangoproject.com/download/

2.安装apache服务器

sudo zypper install apache

插曲:apache2ctl start 时错误

linux:~ # apache2ctl start
httpd2: Syntax error on line 188 of /etc/apache2/httpd.conf: Could not open
configuration file /etc/apache2/sysconfig.d/include.conf: No such file or
directory

解决方法:http://lists.opensuse.org/opensuse-bugs/2011-09/msg01387.html

mkdir -p /etc/apache2/sysconfig.d/ && touch
/etc/apache2/sysconfig.d/include.conf

3.安装apache python接口wsgi

3.1关于wsgi

http://code.google.com/p/modwsgi/

上面站点对wsgi的一段介绍:

The aim of mod_wsgi is to implement a simple to use Apache module which can host any Python application which supports the Python WSGIinterface. The module would be suitable for use in hosting high performance production web sites, as well as your average self managed personal sites running on web hosting services.

3.2安装wsgi

linux:~ # zypper search *wsgi*
Loading repository data...
Warning: Repository 'openSUSE-11.4-Update' appears to outdated. Consider using a different mirror or server.
Reading installed packages...

S | Name             | Summary                               | Type
--+------------------+---------------------------------------+--------
| apache2-mod_wsgi | Python WSGI adapter module for Apache | package

linux:~ # zypper install apache2-mod_wsgi


4.配置Apache使用Ddjango

1.先看看 Apache的配置文件httpd.conf,结构很清晰;修改 loadmoduel.conf,增加mod_wsgi.so。

# Overview of include files, chronologically:
#
# httpd.conf
#  |
#  |-- uid.conf  . . . . . . . . . . . . . .  UserID/GroupID to run under
#  |-- server-tuning.conf  . . . . . . . . .  sizing of the server (how many processes to start, ...)
#  |-- sysconfig.d/loadmodule.conf . . . . .  [*] load these modules

#load wsgi for django
LoadModule wsgi_module                /usr/lib/apache2/mod_wsgi.so
#
2.增加APP
在/etc/apache2/httpd.conf中直接增加如下内容:

#  wsgi app
WSGIScriptAlias / /home/rui.zhao/webserver/mysite/mysite/wsgi.py
WSGIPythonPath /home/rui.zhao/webserver/mysite

# add exec authority
<Directory /home/rui.zhao/webserver/mysite>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
但是官方建议不要在httpd.conf中直接增加,不利于管理:
# Note: instead of adding your own configuration here, consider
#       adding it in your own file (/etc/apache2/httpd.conf.local)
#       putting its name into APACHE_CONF_INCLUDE_FILES in
#       /etc/sysconfig/apache2 -- this will make system updates
#       easier :)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  wsgi django apache Opensuse