最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python?配置uwsgi?啟動Django框架的詳細教程

 更新時間:2022年12月28日 15:08:39   作者:高壓鍋_1220  
這篇文章主要介紹了python?配置uwsgi?啟動Django框架,本文給大家講解的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

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
# 項目目錄
master=true
chdir = /home/oper/simp/Weekreport
wsgi-file = Weekreport/wsgi.py
# 進程數(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命令,項目在/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è)置開機啟動

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/;
  	}
}

到此這篇關(guān)于python 配置uwsgi 啟動Django框架的文章就介紹到這了,更多相關(guān)python  uwsgi 配置內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Blender Python編程實現(xiàn)程序化建模生成超形示例詳解

    Blender Python編程實現(xiàn)程序化建模生成超形示例詳解

    這篇文章主要為大家介紹了Blender Python編程實現(xiàn)程序化建模生成超形示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-08-08
  • Python中的filter()函數(shù)的用法

    Python中的filter()函數(shù)的用法

    這篇文章主要介紹了Python中的filter()函數(shù)的用法,代碼基于Python2.x版本,需要的朋友可以參考下
    2015-04-04
  • python類中super()和__init__()的區(qū)別

    python類中super()和__init__()的區(qū)別

    這篇文章主要介紹了python類中super()和__init__()的區(qū)別,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2016-10-10
  • YOLOv5車牌識別實戰(zhàn)教程(二)理論基礎(chǔ)

    YOLOv5車牌識別實戰(zhàn)教程(二)理論基礎(chǔ)

    這篇文章主要介紹了YOLOv5車牌識別實戰(zhàn)教程(二)理論基礎(chǔ),在這個教程中,我們將一步步教你如何使用YOLOv5進行車牌識別,幫助你快速掌握YOLOv5車牌識別技能,需要的朋友可以參考下
    2023-04-04
  • Python 第一步 hello world

    Python 第一步 hello world

    Python 第一步 hello world 入門學(xué)習(xí)。
    2009-09-09
  • Python Reduce函數(shù)的高級用法詳解

    Python Reduce函數(shù)的高級用法詳解

    這篇文章主要介紹了reduce函數(shù)的工作原理和應(yīng)用,同時提供豐富的示例代碼,方便更好地理解如何使用reduce函數(shù)來輕松解決復(fù)雜的數(shù)據(jù)聚合問題,需要的可以參考下
    2023-11-11
  • Python MongoDB 插入數(shù)據(jù)時已存在則不執(zhí)行,不存在則插入的解決方法

    Python MongoDB 插入數(shù)據(jù)時已存在則不執(zhí)行,不存在則插入的解決方法

    這篇文章主要介紹了Python MongoDB 插入數(shù)據(jù)時已存在則不執(zhí)行,不存在則插入的解決方法,結(jié)合實例形式分析了Python基于日志判斷數(shù)據(jù)是否已經(jīng)插入的相關(guān)操作技巧,需要的朋友可以參考下
    2019-09-09
  • 完美解決Django2.0中models下的ForeignKey()問題

    完美解決Django2.0中models下的ForeignKey()問題

    這篇文章主要介紹了完美解決Django2.0中models下的ForeignKey()問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-05-05
  • Python基本知識之datetime模塊詳解

    Python基本知識之datetime模塊詳解

    這篇文章主要給大家介紹了關(guān)于Python基本知識之datetime模塊的相關(guān)資料,Python內(nèi)置的時間模塊datetime包含下面的模塊包含六個類和兩個常數(shù),提供了用于處理日期和時間的類和對應(yīng)的方法,一般用于處理年、月、日、時、分、秒的統(tǒng)計和計算等需求,需要的朋友可以參考下
    2023-08-08
  • Pandas 解決dataframe的一列進行向下順移問題

    Pandas 解決dataframe的一列進行向下順移問題

    今天小編就為大家分享一篇Pandas 解決dataframe的一列進行向下順移問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12

最新評論

都兰县| 德州市| 平顶山市| 松潘县| 玛曲县| 鸡泽县| 若尔盖县| 河津市| 建阳市| 临湘市| 平湖市| 洞头县| 阜南县| 定兴县| 新邵县| 白玉县| 乌兰察布市| 九寨沟县| 通辽市| 锦州市| 宜兴市| 丹寨县| 连平县| 岗巴县| 北安市| 临沧市| 磴口县| 巴青县| 个旧市| 广安市| 醴陵市| 噶尔县| 巧家县| 新蔡县| 荔波县| 麟游县| 清新县| 白银市| 离岛区| 油尖旺区| 昌平区|