OS : Ubuntu
Python : 2.7.1 1) Install lighttpdsudo apt-get, install lighttpd
I want to download it to / var / www installation,
$ Cd / var / www $ Sudo wget http://media.djangoproject.com/releases/1.3/Django-1.3.1.tar.gz $ Sudo tar xzvf Django-1.3.1.tar.gz $ Cd the Django-1.3.1 $ Sudo python setup.py install
cd / var / www
the sudo django-admin.py startproject the portal the cd the portal sudo the chmod + the x the manage.py sudo python manage.py runserver
Displays the following screen, django has a normal installation
5) install flup
Validating the models ... 0 errors found Django version 1.3.1, using settings 'portal.settings' Development server is running at http://127.0.0.1:8000/ with Quit the server with CONTROL-C.
This is the WSGI Server, before installation, you must first determine the version of the python in the command line input
$ / Var / www / portal $ python Python 2.7.1 + (r271: 86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 to
Ubuntu 11.04 Built-in 2.7.1 version? or because I just have the update?? XD
So we had to select the development flup-1.0.3 version
6)by adding mysite.fcgi
$ Cd / var / www $ Sudo wget http://pypi.python.org/packages/2.7/f/flup/flup-1.0.3.dev_20110405-py2.7.egg # md5 = 1fa9a03ade17f88990340884a1113b5a $ Sudo wget http://peak.telecommunity.com/dist/ez_setup.py $ Sudo python ez_setup.py flup-1.0.3.dev_20110405-py2.7.egg
This code is used to tell the server how to deal with the fastcgi program
#! / Usr / bin / python
import sys, os
# Add a custom Python path.
sys.path.insert (0, / var / www ")
# Switch to the directory of your project. (Optional.)
# Os.chdir ("/ home / user / myproject")
# Set the the DJANGO_SETTINGS_MODULE environment variable.
os.environ ['DJANGO_SETTINGS_MODULE'] = "portal.settings"
from django.core.servers.fastcgi import runfastcgi
runfastcgi (["method = threaded", "daemonize = false"])
Above the red part, be especially careful if you look at the django official website files are written is not the same as the official website of
the paper was wrong, or is the older version of the file XD. I later installed a long time, only to find that there are wrong installation should pay
special attention to Oh! Storage of the above file, enter
7) edit the lighttpd config
the paper was wrong, or is the older version of the file XD. I later installed a long time, only to find that there are wrong installation should pay
special attention to Oh! Storage of the above file, enter
$ For python mysite.fcgiThere will be a long list of things. Find what you see
It worked!
This script file is correct.
Start the fastcgi mode
$ Sudo lighttpd-enable-mod Fastcgi
Then here to note in the / etc / lighttpd / you will see to lighttpd.conf this profile do not move, which is the default. lighttpd read this default will
go to read the folder conf-enabled profile without charge. The start fastcgi mode, so read the default
lighttpd would automatically go read the conf-enabled inside the profile. Set fastcgi
8)Establish runfastcgi the script
go to read the folder conf-enabled profile without charge. The start fastcgi mode, so read the default
lighttpd would automatically go read the conf-enabled inside the profile. Set fastcgi
$ Vim / etc/lighttpd/conf-enabled/10-fastcgi.conf server.modules + = ("mod_fastcgi", "Mod_accesslog ) server.modules + = ("mod_rewrite", Mod_fastcgi under " "Mod_accesslog ) $ SERVER ["socket"] == "172.16.33.10:8000" { server.document-root = "/ var / www / portal" the fastcgi.server = ( Fcgi "=> ( "Localhost" => ( The bin-path = "/ var / www / portal / mysite.fcgi "Socket" => "/ var / www / portal / mysite.sock", "Check-local" => "the disable" ) ), ) alias.url = ( "/ Media" => "/ usr/local/lib/python2.7/dist-packages/django/contrib/admin/media /", ) url.rewrite-once = ( "^ (/ Media. *) $" => "$ 1" ^ / The favicon.ico $ "=>" / media / the favicon.ico "^ (/ *) $" => "/ Mysite.fcgi $ 1" ) }
This script is mainly through the manage.py the command the specified runfcgi parameter operation, this script will be related to things in
order to facilitate the start Fastcgi the server into a script.
9)To remember to to modify runfastcgi execute permissions.
order to facilitate the start Fastcgi the server into a script.
#! / Bin / bash # Replace these three settings. PROJDIR = "/ var / www / portal" PIDFILE = "$ PROJDIR / mysite.pid" SOCKET = "$ PROJDIR / mysite.sock" cd $ PROJDIR if [-f $ PIDFILE]; then kill `cat - $ PIDFILE` rm-f - $ PIDFILE fi the exec / usr / bin / env - \ PYTHONPATH is = ".. / Python: .." \ . / Manage.py runfcgi socket = $ SOCKET pidfile = $ PIDFILE
$ Sudo chmod + x runfastcgi
$ / Etc / init.d / the lighttpd
$. / Runfastcgi
You will able to see start page of your django site.
13 )File permissions
drwxr--xr-x 2 www-data root 4096 2011-09-22 19:42 the portal portal folder inside the file are as follows: - Rw-r - r - 1 www-data root 0 2011-09-22 19:16 __ init__.py -Rw-r - r - 1 www-data root 124 2011-09-22 19:17 __ init__.pyc -Rwxrwxrwx 1 www-data root 503 2011-09-22 19:16 the manage.py -Rwxrwxrwx 1 www-data root 401 2011-09-22 7:22 p.m. mysite.fcgi -Rwxrwxrwx 1 www-data root 334 2011-09-22 19:31 runfastcgi -Rw-r - r - 1 www-data root 5031 2011-09-22 19:16 your settings.py -Rw-r - r - 1 www-data root 2652 2011-09-22 19:17 settings.pyc -Rw-r - r - 1 www-data root 565 2011-09-22 19:16 The urls.py -Rw-r - r - 1 www-data www-data 261 2011-09-22 19:42 urls.pyc
Modify the lighttpd config.
alias.url = ("/ static / admin /" => "/ usr/local/lib/python2.7/dist-packages/django/contrib/admin/media /")
[Reference]
http://blog.finalevil.com/2011/09/how-to-use-django-on-lighttpd-with.html
Hi, I tried to follow your steps here but stuck at number 4. after I've done
ReplyDeletesudo chmod +x manage.py
Then I ran the line
sudo python manage.py runserver
but this error came out,
sudo: manage.py: command not found
Can you help me here? I've followed your steps faithfully until number 4 where I stuck there.