文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>freebsd下安装apache+mod_python+django

freebsd下安装apache+mod_python+django

时间:2008-02-22  来源:mageguoshi

1、系统环境
freebsd6.2,pthon2.4

1、apache的安装
# cd /usr/ports/www/apache22/
# make install clean

2、mod_python的安装
# cd /usr/ports/www/mod_python3
# make install clean

3、django的安装
# cd /usr/ports/www/py-django
# make install clean     //选择适当的数据库,这里我选择了mysql和cgi

4、建立django项目gr
# mkdir /django
# cd /django
# django-admin.py startproject gr

5、配置apache
# vim /usr/local/etc/apache22/httpd.conf
添加下面的几行
Alias /django /django/gr
<Directory /django/gr>
        SetHandler python-program
        PythonPath "['/django'] + sys.path"
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE gr.settings
        PythonAutoReload Off
        PythonDebug On
        Order allow,deny
        Allow from all
</Directory>

6、创建一个py文件
# cd /django/gr
# vim helloworld.py

#!/usr/bin/python
from django.http import HttpResponse
def index(request):
        return HttpResponse('Hello, Django!')

7、修改urls.py
# vim  /django/gr/urls.py
urlpatterns = patterns('',
    # Example:
    # (r'^gr/', include('gr.foo.urls')),
      (r'^django/hello/', 'gr.helloworld.index'),
    # Uncomment this for admin:
#     (r'^admin/', include('django.contrib.admin.urls')),
)

8、运行测试
http://192.168.2.11/django/hello/

9、安装mysql的数据库引擎

# wget http://jaist.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.2.tar.gz
# tar zxf MySQL-python-1.2.2.tar.gz
# cd MySQL-python
# vim site.cfg
mysql_config = /usr/local/bin/mysql_config
改为
mysql_config = /usr/local/mysql/bin/mysql_config

# python setup.py buidl && python setup.py install

10、djaogo的数据库配置
# vim /django/gr/settings.py

DATABASE_ENGINE = 'mysql'
DATABASE_NAME = ''
DATABASE_USER = 'root'
DATABASE_PASSWORD = ''
DATABASE_HOST = 'localhost'
DATABASE_PORT = '3306'
相关阅读 更多 +
排行榜 更多 +
找茬脑洞的世界安卓版

找茬脑洞的世界安卓版

休闲益智 下载
滑板英雄跑酷2手游

滑板英雄跑酷2手游

休闲益智 下载
披萨对对看下载

披萨对对看下载

休闲益智 下载