Setting for Python + Django on iPad 5.1.1

1. Go to Cydia, Let’s install some packages.
– mysql
– python
– lighttpd

2. First of all, we have to set up ‘.vimrc’ file.
# cd /var/mobile/
# vi .vimrc
paste this configure to .vimrc!

:nmap  
:nmap  
:nmap  
:nmap  

:imap ` 
:nmap ` :sp:o ./
:nmap :o ./
:nmap ! 
:nmap = +
:nmap - -
:nmap F 
:nmap B 
:nmap VV 
:nmap U 

set nocompatible
set autoindent
set cindent
set smartindent
set wrap
set nowrapscan
set nobackup
set visualbell
set ruler
set shiftwidth=4
set number
set fileencoding=utf-8
set tenc=utf-8
set expandtab
set hlsearch
set ignorecase
set tabstop=4
set lbr
set incsearch
syntax on
filetype indent on
set background=dark
colorscheme desert
set backspace=eol,start,indent
set history=1000

:nmap - :tabp
:nmap = :tabn

You can use tab browser options when you press ‘t’ key in the browser mode and If you use this configure, It would be able to look editor clearly.

3. Install Easy_Install !!
First, you have to visit Easy_Install site for python. and download ‘setuptools-0.6c11-py2.5.egg’
like this.

# sh setuptools-0.6c11-py2.5.egg

if your machine have this package, it would be able to install some package for python.
for example,

# pip django

after execute this command, the ‘pip’ program will search for some package to need automatically and install it.

And, you have to install this package for running django server!

webterror-iPad:~/django/study mobile$ su -
Password:
webterror-iPad:~ root# easy_install flup
Searching for flup
Reading http://pypi.python.org/simple/flup/
Reading http://www.saddi.com/software/flup/
Best match: flup 1.0.3.dev-20110405
Downloading http://pypi.python.org/packages/2.5/f/flup/flup-1.0.3.dev_20110405-py2.5.egg#md5=dec8a20ea55b7504291cf7aae779c3c4
Processing flup-1.0.3.dev_20110405-py2.5.egg
Moving flup-1.0.3.dev_20110405-py2.5.egg to /private/var/stash/python2.5.uKKes9/site-packages
Adding flup 1.0.3.dev-20110405 to easy-install.pth file

Installed /private/var/stash/python2.5.uKKes9/site-packages/flup-1.0.3.dev_20110405-py2.5.egg
Processing dependencies for flup
Finished processing dependencies for flup
webterror-iPad:~ root# exit

5. Edit lighttpd.conf configure file, for django.
# vim /etc/lighttpd2.conf

#server.document-root = "/var/mobile/"
server.document-root = "/var/mobile/django/study"
server.port = 80 # Default
server.modules = ( "mod_cgi", "mod_access", "mod_alias", "mod_rewrite", "mod_compress", "mod_fastcgi", "mod_indexfile", "mod_dirlisting", "mod_accesslog" )

server.tag = "iPhone lighttpd"
server.name = "any.localhost.org"

server.pid-file = "/var/run/lighttpd.pid"
dir-listing.activate = "enable"
#dir-listing.external-css = "/.dirlist/iphonedirlist.css"
 
index-file.names = ( "index.php", "index.py", "index.pl", "index.cgi", "index.html", "default.html", "/.dirlist/dir-generator.py" )
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi", ".cgi", ".py" )
 
cgi.assign = ( ".pl"  => "/usr/bin/perl", ".py" => "/usr/bin/python", ".rb" => "/usr/local/bin/ruby", ".cgi" => "", ".sh" => "", ".php" => "/usr/bin/php-cgi" )

# you must type this part.
fastcgi.server = (
  "/study.fcgi" => (
      "main" => (
          "socket" => "/tmp/study.sock",
          "check-local" => "disable",
      )
  ),
)

url.rewrite-once = (
    "^(/.*)$" => "/study.fcgi$1",
)
# by this point.

mimetype.assign             = (
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "application/ogg",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".cpp"          =>      "text/plain",
  ".log"          =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar",
  # default mime type
  ""              =>      "application/octet-stream",
)

6. Go to terminal
# su –
# killall -9 lighttpd
# lighttpd -f /etc/lighttpd2.conf

7. go to your project directory of django. Try to run python django server.
webterror-iPad:~/django/study mobile$ python manage.py runfcgi method=threaded socket=/tmp/study.sock pidfile=/tmp/study.pid daemonize=false

8. Connect to ‘http://localhost’. if you see this screen, it is complete to setting up for django.

20121118-184434.jpg

관련 글

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 항목은 *(으)로 표시합니다