網(wǎng)站首頁 編程語言 正文
1. 安裝pip3
yum install python34-pip
2. 安裝python34devel
yum install python34-devel
3. pip3 安裝依賴
pip3 install -r requirements
4. 安裝uwsgi
pip3 install uwsgi
編寫test.py測試uwsgi
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
return [b"Hello World"] # python3
#return ["Hello World"] # python2
uwsgi --http :9090 --wsgi-file test.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191
5. uwsgi 配置 (simp)
編寫uwsgi.ini,以wsgi方式啟動uwsgi,此時無法通過web訪問的方式測試是否啟動,
#uwsgi配置文件
[uwsgi]
# 轉(zhuǎn)發(fā)給nginx 的端口
socker=:9000
#http=:9000
# 項(xiàng)目目錄
master=true
chdir = /home/oper/simp/Weekreport
wsgi-file = Weekreport/wsgi.py
# 進(jìn)程數(shù)
workers = 5
processes = 5
threads = 2
buffer-size = 130000
# 設(shè)置日志目錄
daemonize = /home/oper/simp/Weekreport/log/uwsgi.log
stats=%(chdir)/uwsgi/uwsgi.status
pidfile=%(chdir)/uwsgi/uwsgi.pid
uwsgi啟動的linux shell命令,項(xiàng)目在/home/oper/simp/Weekreport下
# 啟動
uwsgi --ini /home/oper/Weekreport/uwsgi.ini
# 停止
uwsgi --stop /home/oper/Weekreport/uwsgi/uwsgi.pid
# 啟動
uwsgi --ini /home/oper/Weekreport/uwsgi.ini
# 停止
uwsgi --stop /home/oper/Weekreport/uwsgi/uwsgi.pid
如控制臺出現(xiàn)以下提示,八成是成功了
WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x12b9fa0 pid: 2402 (default app)
mountpoint already configured. skip.
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI worker 1 (and the only) (pid: 2402, cores: 1)
啟動uwsgi服務(wù),設(shè)置開機(jī)啟動
systemctl start uwsgi
systemctl enable uwsgi
6. nginx的配置
6.1 uwsgi 后端nginx 配置
在/etc/nginx/conf.d下新建一個uwsgi.conf
```bash
# mysite_nginx.conf
# configuration of the server
server {
# the port your site will be served on
listen 80 default_server;
server_name localhost;
charset utf-8;
access_log /applog/nginx/logs/access.log main;
proxy_set_header Host $host;
proxy_set_header X-Real_ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_read_timeout 300
location / {
include uwsgi_params;
uwsgi_pass 28.106.81.81:9000
}
location /api/{
proxy_pass http://28.106.81.81:8080/;
}
location /collection/{
proxy_pass http://localhost:9999/;
}
location /api-collection/{
proxy_pass http://localhost/collection/api/;
}
}
6.2 nginx 前端nginx 配置
在/etc/nginx/conf.d下新建一個uwsgi.conf
# mysite_nginx.conf
# configuration of the server
server {
# the port your site will be served on
listen 80 default_server;
# the domain name it will serve for
server_name simp;
charset utf-8;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location / {
proxy_pass http://28.106.81.81; # 此處是uwsgi 對應(yīng)的后端Nginx
# uwsgi_pass localhost:5000; # 此處與uwsgi.ini的socket是對應(yīng)的
}
location /static {
alias /root/hujun_app/ocv-simp/Weekreport/static; # your Django project's static files - amend as required
}
location /api-collection/{
proxy_pass http://localhost/collection/api/;
}
location /collection/{
proxy_pass http://localhost:9999/;
}
}
原文鏈接:https://blog.csdn.net/u014651560/article/details/128419846
相關(guān)推薦
- 2022-12-12 使用PlatformView將?Android?控件view制作成Flutter插件_Android
- 2022-04-20 C語言數(shù)據(jù)結(jié)構(gòu)與算法時間空間復(fù)雜度基礎(chǔ)實(shí)踐_C 語言
- 2022-10-04 Android實(shí)現(xiàn)圓圈倒計(jì)時_Android
- 2022-11-30 golang中的defer函數(shù)理解_Golang
- 2022-10-19 React封裝彈出框組件的方法_React
- 2022-03-16 C++訪問者模式模板函數(shù)無法重載的問題解決_C 語言
- 2022-05-18 python中l(wèi)eastsq函數(shù)的使用方法_python
- 2022-04-28 WPF使用DockPanel停靠面板布局_實(shí)用技巧
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支