Ubuntu 14.04 + Apache2 + Django setup

Install dependence

  1. Install apache2
$sudo apt-get install apache2 apache2-dev

Check apxs

$ apxs2
  1. Install python dev
$sudo apt-get install python-dev
  1. Install mod_wsgi
    Download from https://github.com/GrahamDumpleton/mod_wsgi/releases
$ wget https://github.com/GrahamDumpleton/mod_wsgi/archive/4.4.21.tar.gz
$ tar zxvf 4.4.21.tar.gz
$ cd mod_wsgi-4.4.21
$ ./configure
or
$ ./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/local/bin/python
$ make
$ sudo make install
# Will create a mod_wsgi.so to modules: /usr/lib/apache2/modules/mod_wsgi.so
  1. Install django
$ sudo -E pip install django
# Check
$ django-admin help
# Django docs: https://www.djangoproject.com/start/

Create your Django projects

  1. Create an simple django project
$ django-admin startproject BobServer
# Check your project
$ cd BobServer
$ python manage.py runserver

Setup apache conf for your project

  1. Create django conf for apache2 http://www.rackspace.com/knowledge_center/article/ubuntu-modwsgi-installation
$ cd /etc/apache2/sites-available
$ sudo vim django.conf
# add below info
"""
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

WSGIScriptAlias /bobserver /home/bob/github/BobServer/BobServer/wsgi.py
WSGIPythonPath /home/bob/github/BobServer/:/usr/local/lib/python2.7/dist-packages/;/usr/local/bin/

<Directory /home/bob/github/BobServer>
        #Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
        <Files wsgi.py>
                Require all granted
        </Files>
</Directory>

ErrorLog ${APACHE_LOG_DIR}/BobServer.log
"""
# add soft link in sites-enabled
$ sudo ln -s django.conf ../sites-available/django.conf
# Restart apache2
$ sudo service apache2 restart
# To check your setup, open browser and go to your server url
# xxxxxx.com/bobserver
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值