Public Repository

Last pushed: 10 months ago
Short Description
Short description is empty for this repo.
Full Description

1:安装docker,确认版本,Xenial 16.04 (LTS)
https://docs.docker.com/engine/installation/linux/ubuntu/
坑:无法挂载硬盘,内核问题
https://github.com/docker/docker/issues/29798

2:运行docker的容器
docker run -p 80:80 -itd -v /home:/home 0ef2e08ed3fa
3.1:更新并安装初步python环境和虚拟环境
apt-get update
apt-get install vim
apt-get install python3-pip
pip3 install virtualenv

3:安装django+uwsgi+nginx
http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html
3.1:virtualenv
virtualenv /home/env001
source /home/env001/bin/activate
3.2:django
pip install django==1.10.6
pip install pillow==4.0.0
pip install jieba==0.38
pip install xpinyin==0.5.5
pip install xlrd==1.0.0
pip install pymysql
3.3:uwsgi
pip install uwsgi
uwsgi --http :80 --wsgi-file test.py 测试uwsgi
python manage.py runserver 0.0.0.0:80 测试django
uwsgi --http :80 --module testdjango.wsgi 测试uwsgi
3.4:nginx
apt-get install nginx
/etc/init.d/nginx start
3.4.1:配置nginx
http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html#configure-nginx-for-your-site
修改:
listen 80;
/media {alias /home/testdjango/media}
/static {alias /home/testdjango/static};
include;/etc/nginx/uwsgi_params
快捷链接:
ln -s /home/nginx/test_nginx.conf /etc/nginx/sites-enabled/
重启:
/etc/init.d/nginx restart
3.5:测试nginx+uwsgi
uwsgi --socket :8000 --wsgi-file test.py
3.5.1:用sock替换端口
修改nginx配置
unix:///home/uwsgi/testdjango.sock
/etc/init.d/nginx restart
3.5.2:测试
uwsgi --socket testdjango.sock --wsgi-file test.py
坑(/var/log/nginx/error.log):unix:///home/uwsgi/testdjango.sock failed (2: No such file or directory)
uwsgi --socket /home/uwsgi/testdjango.sock --wsgi-file test.py --chmod-socket=666
3.5.3:测试django程序
uwsgi --socket /home/uwsgi/testdjango.sock --module testdjango.wsgi --chmod-socket=666
3.6:编写test_uwsgi.ini
http://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html#configuring-uwsgi-to-run-with-a-ini-file
chmod-socket = 666
3.6.1:运行
uwsgi --ini /home/uwsgi/test_uwsgi.ini

4:退出虚拟环境后修正uwsgi
deactivate
pip install uwsgi
uwsgi --ini /home/uwsgi/test_uwsgi.ini

5:上帝模式
mkdir /etc/uwsgi
mkdir /etc/uwsgi/vassals
ln -s /home/uwsgi/test_uwsgi.ini /etc/uwsgi/vassals/
uwsgi --emperor /etc/uwsgi/vassals

6:外部执行
docker exec 42bb58fcb232 uwsgi --emperor /etc/uwsgi/vassals

7:把以上步骤保存为一个image
docker commit 42bb58fcb232 jish:001
docker tag 5660ccff2618 jianshaobh/ubuntu:001
docker push jianshaobh/ubuntu

Docker Pull Command
Owner
jianshaobh