sudo apt-get install build-essential autoconf \
libtool pkg-config python-opengl python-imaging \
python-pyrex python-pyside.qtopengl idle-python2.7 \
qt4-dev-tools qt4-designer libqtgui4 libqtcore4 \
libqt4-xml libqt4-test libqt4-script libqt4-network \
libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev
pip install channels
#maybe pip --trusted-host pypi.python.org install channels
此时还需要安装redis。
pip install asgi_redis
apt-get install redis-server
daphne chat.asgi:channel_layer --port 80 --bind 0.0.0.0 -v2 &
如果要设置其它端口,是不能解析A纪录的域名的。除非使用反向代理。
如果组件版本低,就安装最新的。
pip install six --upgrade
# maybe sudo pip install twisted --upgrade
# sudo pip install txaio
# sudo -E easy_install twisted
4 启动runworker
./manage.py runworker &
附带Dockerfile
FROM ubuntu:14.04
MAINTAINER yzh
RUN apt-get update && apt-get install -y \
# wget \
# vim \
python-dev \
python-setuptools \
build-essential \
redis-server \
libtiff5-dev libjpeg8-dev zlib1g-dev \
libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
# apache2 \
# libapache2-mod-php5
RUN easy_install pip
RUN pip install channels
RUN pip install asgi_redis
RUN pip install six --upgrade
RUN pip install pillow
#RUN pip install gunicorn
RUN echo "service redis-server start" > /home/runall.sh
RUN echo "cd /home/web" >> /home/runall.sh
RUN echo "nohup daphne chat.asgi:channel_layer --port 80 --bind 0.0.0.0 -v2&" >> /home/runall.sh
RUN echo "nohup ./manage.py runworker &" >> /home/runall.sh
RUN echo "/bin/bash" >> /home/runall.sh
如果去掉了chat组件,就可以用简单的方式来部署
Dockerfile
FROM ubuntu:14.04
MAINTAINER yzh
RUN apt-get update && apt-get install -y \
python-dev \
python-setuptools \
gcc
RUN easy_install pip
RUN pip install django pillow
RUN pip install gunicorn
run echo "cd /home/web/" > "/home/run.sh"
run echo "gunicorn --bind=0.0.0.0:8000 \$1.wsgi:application" >> "/home/run.sh"