mysql
收集静态文件
nginx配置
# For more information on configuration, see:
# * Official English Documentation: http://nginx.org/en/docs/
# * Official Russian Documentation: http://nginx.org/ru/docs/
user root;
worker_processes 4;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
#types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
server {
listen 80;
#server_name ;
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
location /static {
alias /data/s4/deploy/uuuuuu; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include uwsgi_params; # the uwsgi_params file you installed
}
}
}
Django部署:
1. 租云服务器
2. 买服务器
租:公网IP,111.13.101.208
租域名:www.pythonav.com <-> 111.13.101.208
3. 编写代码
4. 拷贝代码到服务器[Python,Django,pymysql,sqllite]
5.
settings.py
ALLOWED_HOSTS = ['服务器',]
python manage.py runserver 0.0.0.0:8001
使用:
遵循wsig协议:
wsgiref
6. uwsgi
pip3 intall uwsgi
简单测试:
app.py
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"]
uwsgi --http :9001 --wsgi-file app.py
uwsgi --http :9002 --wsgi-file foobar.py --master --processes 4 --threads 2
Django:
# 不处理静态文件
uwsgi --http :9002 --chdir /data/s4/deploy --wsgi-file deploy/wsgi.py --master --processes 4 --threads 2
STATICFILES_DIRS = (
os.path.join(BASE_DIR,'static'),
)
STATIC_ROOT = os.path.join(BASE_DIR,'uuuuuu')
python manage.py collectstatic
完事,注释静态配置
# 处理静态文件
uwsgi --http :9003 --chdir /data/s4/deploy --wsgi-file deploy/wsgi.py --static-map /static=/data/s4/deploy/uuuuuu
# 写一个配置文件
wsgi_http.ini
[uwsgi]
http = 0.0.0.0:9004
chdir = /data/s4/deploy
wsgi-file = deploy/wsgi.py
# processes = 4
# threads = 2
static-map = /static=/data/s4/deploy/uuuuuu
uwsgi wsgi_http.ini
7. Nginx
yum install nginx
/etc/init.d/nginx start/stop/restart
/etc/nginx/nginx.conf
[uwsgi]
socket = 127.0.0.1:8001
chdir = /data/s4/deploy
wsgi-file = deploy/wsgi.py
# processes = 4
# threads = 2
static-map = /static=/data/s4/deploy/uuuuuu
bs4
django
Pillow
来源:oschina
链接:https://my.oschina.net/u/4387359/blog/4049135