OpenSuse11.4+Apache+Django搭建Webserver

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 :)


转载于:https://my.oschina.net/234148609/blog/155219

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值