资源说明:
Command which you need:
sudo apt-get install python-dev
sudo easy_install -U gunicorn
sudo apt-get install nginx
sudo apt-get install postgresql
sudo apt-get install postgresql-server-dev-9.1
sudo apt-get install python-lxml
Unwrap project:
git clone git://github.com/alexkos/picker.git
pip install -r requirements.txt
Copy and put your settings from local_settings_default.py in local_settings.py and add in git ignore which store into picker of directory:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'name_your_db',
'USER': 'your_user_db',
'PASSWORD': 'your_password',
'HOST': 'localhost',
'PORT': '',
}
}
EMAIL_HOST = 'your_smpt_server'
EMAIL_HOST_USER = 'your_email'
DEFAULT_FROM_EMAIL = 'your_email'
EMAIL_HOST_PASSWORD = 'your_password_email'
EMAIL_PORT = 'port'
Must be installed PostgreSQL in system, if not then to make command:
sudo -u postgres createuser -P name_user_db
su postgres
psql
CREATE DATABASE database_name OWNER name_admin ENCODING 'UTF8';
Edit the Postgres permissions in /etc/postgresql/9.1/main/pg_hba.conf by adding a line as follows after the postgres user line:
local database_name name_user_db md5
host all all 0.0.0.0/0 md5
Then:
sudo /etc/init.d/postgresql restart
After installing psycopg:
pip install psycopg2
or
easy_installed psycopg2
Create tables in django project:
./manage.py syncdb
username: name_admin
email:your_email
password: password
Then to perform command in root project, where is
./manage.py migrate capturing
./manage.py collectstatic
Put in *.sh script:
#!/bin/bash
set -e
#Create file and give it access rights:
LOGFILE=/var/log/gunicorn/picker.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=2
# user/group to run as
# (username) and (usergroup)
USER=user
GROUP=user
echo "start service"
cd /home/user/project/picker
test -d $LOGDIR || mkdir -p $LOGDIR
gunicorn_django -w $NUM_WORKERS \
--user=$USER --group=$GROUP --daemon --log-level=debug \
--log-file=$LOGFILE 2>>$LOGFILE
Create conf file for nginx:
server {
listen 80;
server_name yourdomain_name.domain;
# no security problem here, since / is alway passed to upstream
root /path/to/your/project/;
# serve directly - analogous for static/staticfiles
location /media/ {
# if asset versioning is used
if ($query_string) {
expires max;
}
}
location /static/ {
alias /path/to/your/project/staticfiles/;
autoindex off;
}
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_read_timeout 10;
proxy_pass http://localhost:8000/;
}
# what to serve if upstream is not available or crashes
error_page 500 502 503 504 /media/50x.html;
}
If appear problem with database, use command:
./manage.py dbshell
Perform command in:
ALTER TABLE capturing_textsite ADD COLUMN text_tsv tsvector;
CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE ON capturing_textsite FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger(text_tsv, 'pg_catalog.english', text);
CREATE INDEX capturing_textsite_tsv ON capturing_textsite USING gin(text_tsv);
UPDATE capturing_textsite SET text_tsv=to_tsvector(text);
http://se888.wordpress.com/2012/05/26/%D0%BF%D0%BE%D0%BB%D0%BD%D0%BE%D1%82%D0%B5%D0%BA%D1%81%D1%82%D0%BE%D0%B2%D1%8B%D0%B9-%D0%BF%D0%BE%D0%B8%D1%81%D0%BA-%D0%B4%D0%BB%D1%8F-django-2/
added in local_setting for django-sphinx:
SPHINX_SERVER = 'localhost'
SPHINX_PORT = 9312
SPHINX_API_VERSION = 0x116
本源码包内暂不包含可直接显示的源代码文件,请下载源码包。
English
