部署django项目到linux服务器

uwsgi后台运行/背后运行/守护运行的方法
uwsgi -d --ini uwsgi.ini

加上 -d 就达到目的了。

后台杀掉uwsgi进程
pkill -f uwsgi -9

更新nginx配置
/usr/sbin/nginx -s reload -c /etc/nginx/my.conf

保持nginx启动
systemctl enable nginx

项目持续运行
nohup python manage.py runserver 0.0.0.0:xxxx &

uwsgi.ini

# uwsgi.ini file
[uwsgi]

# Django-related settings

http =IP/域名:端口号

# the base directory (full path)
chdir =项目路径

# Django s wsgi file
module          = agri.wsgi

# process-related settings
# master
master          = true

# maximum number of worker processes
processes       = 4

# ... with appropriate permissions - may be needed
# chmod-socket    = 664
# clear environment on exit
vacuum          = true

my.conf

user  root;
worker_processes  1;

error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
	worker_connections  1024;
}

http {
	upstream vueshop{
	        # 和wsgi进行动态请求传输的设置
	        server 127.0.0.1:端口号; # TCP socket
	}
	include    /etc/nginx/mime.types;
	default_type  application/octet-stream;
	sendfile        on;

	keepalive_timeout  65;
	

	server {
		#下面是绑定的端口和IP
		listen  端口号;
		server_name  localhost;
		charset     utf-8;
		location /media {
			alias /项目路径/media;
		}
	        location /static {
            		alias /项目路径/static; # your Django project's static files - amend as required
        	}
		location / {	
			uwsgi_pass vueshop;
			include /etc/nginx/uwsgi_params;
		}
	}
}

你可能感兴趣的:(django,django,python)