参考资料:
http://eshlox.net/en/2012/09/11/nginx-uwsgi-virtualenv-and-django-ubuntu-1204/
https://virtualenv-chinese-docs.readthedocs.org/en/latest/
https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
http://www.virtualenv.org/en/latest/
在virtualenv环境下安装 mysqldb的时候遇到几个问题
$ sudo apt-get install libmysqlclient-dev
$ sudo apt-get install python-dev
把第一个链接的文章转过来,防止以后不能访问,其他几个都是官方文档,主要还是参考官方文档。
First install required applications.
Versions of packages that will be used:
Virtualenv.
I store my project in ~/projects. Now I'm creating python virtual environment for my project and I'm installing Django.
Nginx configuration.
IMHO, by default, nginx is configured for basic tasks. I won't change this configuration in this entry. Configuration files are stored in /etc/nginx/sites-available. Go to this directory and create a new file.
It's example configuration.
We must create symlink to enable this.
Uwsgi.
Like with Nginx.. configuration files are stored in /etc/uwsgi/apps-available. Go to this directory and create a new file.
Enable this.
That's all. Now, run this services.
Of course, this is a very basic configuration. Change it according to your needs.
sudo apt-get install nginx uwsgi uwsgi-plugin-python python-virtualenv
Nginx 1.1.19.1
Uwsgi 1.0.3+dfsg-1ubuntu0.1
Virtualenv 1.7.1.2-1
Django 1.4.1
cd ~/projects/ virtualenv eshlox.net cd eshlox.net source bin/activate pip install django django-admin.py startproject project
cd /etc/nginx/sites-available vim eshlox.net
server { listen 80; server_name eshlox.net www.eshlox.net; access_log /var/log/nginx/eshlox.net_access.log; error_log /var/log/nginx/eshlox.net_error.log; location / { uwsgi_pass unix:///tmp/eshlox.net.sock; include uwsgi_params; } location /media/ { alias /home/eshlox/projects/eshlox.net/project/project/media/; } location /static/ { alias /home/eshlox/projects/eshlox.net/project/project/static/; } }
cd /etc/nginx/sites-enabled ln -s ../sites-available/eshlox.net .
cd /etc/uwsgi/apps-available vim eshlox.net.ini
[uwsgi] vhost = true plugins = python socket = /tmp/eshlox.net.sock master = true enable-threads = true processes = 2 wsgi-file = /home/eshlox/projects/eshlox.net/project/project/wsgi.py virtualenv = /home/eshlox/projects/eshlox.net chdir = /home/eshlox/projects/eshlox.net/project touch-reload = /home/eshlox/projects/eshlox.net/project/reload
cd /etc/uwsgi/apps-enabled/ ln -s ../apps-available/eshlox.net.ini .
sudo service nginx start sudo service uwsgi start
上一篇: git flow使用
下一篇: ubuntu virtualenv下crontab编写执行python脚本
0 Responses so far.