架设在线视频服务器,在线视频爬虫与百度云盘同步服务及其服务器架设(二)

本文介绍了如何在Ubuntu系统上使用Nginx和uWSGI部署Django web项目。首先通过`sudo apt-get install nginx`安装Nginx,然后配置Nginx的服务器块以指向Django应用。接着,安装uWSGI并创建uWSGI配置文件,设置项目运行端口、模块路径等。最后,启动和管理Nginx及uWSGI服务,确保项目正常运行。
摘要由CSDN通过智能技术生成

Nginx部署

在ubunt下面安装nginx

sudo apt-get install nginx #安装

nginx操作

service nginx start #运行nginx

service nginx stop #停止nginx

service nginx restart #重新运行nginx

nginx配置

# the upstream component nginx needs to connect to

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)

}

# configuration of the server

server {

# the port your site will be served on

listen 8000;

# the domain name it will serve for

server_name 127.0.0.1; # substitute your machine's IP address or FQDN

charset utf-8;

send_timeout 3000;

# uwsgi_read_timeout 3000;

error_log /home/video_crawler/error.log;

# max upload size

client_max_body_size 75M; # adjust to taste

# Django media

location /media {

alias /home/video_crawler/media; # your Django project's media files - amend as required

}

location /static {

alias /home/video_crawler/static; # your Django project's static files - amend as required

}

# Finally, send all non-media requests to the Django server.

location / {

uwsgi_pass django;

include /home/video_crawler/uwsgi_params; # the uwsgi_params file you installed

}

}

listen为对外监听端口

upstream django 对uwsgi 设定的端口

send_time为设置nginx监听事件的参数,防止504错误出现

映射nginx 配置文件

sudo ln -s ~/path/to/your/mysite/mysite_nginx.conf /etc/nginx/sites-enabled/

uwsgi部署

用pip安装uwsgipip install uwsgi

uwsgi配置及运行

建立uwgsi.ini配置文件

# myweb_uwsgi.ini file

[uwsgi]

# Django-related settings

#http = :8001

#socket = /home/youtube_crawler/test.sock

socket = :8001

# the base directory (full path)

chdir = /home/video_crawler

# Django s wsgi file

module = youtube_crawler.wsgi

# process-related settings

# master

master = true

buffer-size =65535

# maximum number of worker processes

processes = 4

# ... with appropriate permissions - may be needed

# chmod-socket = 664

# clear environment on exit

vacuum = true

daemonize = /home/video_crawler/uwsgi.log

socket表示项目运行端口

module为Django项目中wsgi文件位置

daemnize为后台运行uwsgi程序及保存log文件的地址

uwsgi uwsgi.ini即可运行uwsgi程序

uwsgi中止运行

按照端口进行查询lsof -i :8001

然后根据PID可以kill相关程序sudo kill -9 2208 2209

或者按照程序名称查询ps aux | grep uwsgi

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值