摘要:首先要安裝因?yàn)橄到y(tǒng)已經(jīng)裝了所以接下來直接裝虛擬環(huán)境建立一個(gè)獨(dú)立于系統(tǒng)的虛擬環(huán)境不會跟系統(tǒng)環(huán)境混淆運(yùn)行環(huán)境退出環(huán)境運(yùn)行虛擬環(huán)境,在環(huán)境中安裝新建項(xiàng)目新建不用也可以進(jìn)行接下來的操作官網(wǎng)安裝在虛擬環(huán)境中檢測是否正常工作在與同目錄下寫一個(gè)模擬
1. virtualvenv 2. django 3. uWSGI 4. nginx 1. virtualvenv
virtualvenv install
首先要安裝python3
因?yàn)橄到y(tǒng)已經(jīng)裝了 python3.6 所以接下來直接裝虛擬環(huán)境 virtualvenv
mkdir yourwebproject folder cd yourwebproject /usr/python3.6/bin/python3.6 -m venv venv #建立一個(gè)獨(dú)立于系統(tǒng)的虛擬環(huán)境 不會跟系統(tǒng)環(huán)境混淆 source venv/bin/activate #運(yùn)行環(huán)境 deactivate #退出環(huán)境2. django
運(yùn)行虛擬環(huán)境,在環(huán)境中安裝django
pip install django
新建項(xiàng)目
1). django-admin startproject proName 2). cd proName 3). python manage.py runserver # run
新建app
不用也可以進(jìn)行接下來的操作
3. uWSGI官網(wǎng): https://uwsgi-docs.readthedoc...
安裝在虛擬環(huán)境中
pip install uwsgi檢測 uwsgi 是否正常工作
在與venv同目錄下寫一個(gè)模擬站點(diǎn)文件 test.py
# test.py def application(env, start_response): start_response("200 OK", [("Content-Type","text/html")]) return [b"Hello World"] # python3
運(yùn)行
uwsgi --http :8080 --wsgi-file test.py # 假設(shè)訪問端口號8080
瀏覽器訪問
http://serverIP:8080
若顯示站點(diǎn)文件中的輸出,說明uwsgi生效
路徑 web client <-> uwsgi <-> python
部署 django首先運(yùn)行django確保django能正常工作
python manage.py runserver 0.0.0.0:8000
在manage.py同級目錄下運(yùn)行
uwsgi --http :8080 --module djangoProName.wsgi
--module djangoProName.wsgi 代表 djangoProName 目錄下的 wsgi.py 文件
瀏覽器訪問
http://serverIP:80804. nginx
官網(wǎng): https://www.nginx.com/resourc...
不在虛擬環(huán)境中安裝
由于服務(wù)器上已經(jīng)安裝了 nginx 所以安裝步驟省略,只需要在 nginx.conf 中添加配置即可。
配置 nginx
nginx.conf 結(jié)構(gòu):
user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; } http { # server{ ... } }
添加 server
server { listen 98 default_server; # 訪問時(shí)輸入的端口 本地和外部瀏覽器后面都要加這個(gè)端口號 server_name 10.41.95.85; # 自己網(wǎng)站的域名 # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { # location : 文件系統(tǒng)配置 去應(yīng)答一些要服務(wù)器資源的請求 include uwsgi_params; uwsgi_pass 127.0.0.1:9898; # 與ini文件對接端口 與上面的 93 端口沒有關(guān)系 } }
配置完了之后記得重啟nginx
配置 uwsgi
將配置項(xiàng)全部寫入ini文件
在venv同目錄下自己新建uwsgi的ini文件
[uwsgi] socket = 127.0.0.1:9898 ; 與 nginx 對接 IP ; django pro dir chdir = /root/Odin/TrackManagement/TrackManagement/ ; django project dir wsgi-file = TrackManagement/wsgi.py ; 代表 TrackManagement 目錄下的 wsgi.py 文件 ; module = TrackManagement.wsgi ; 有上面的wsgi配置這個(gè)就不用寫了 processes = 2 ; 進(jìn)程 threads = 1 ; 線程 stats = 127.0.0.1:9696 ; 內(nèi)部配置訪問ip 與socket區(qū)別開
瀏覽器訪問
http://10.41.95.85:98
若顯示django畫面 則 uwsgi+nginx生效
路徑 web client <-> nginx <-> uwsgi <-> django
uwsgi: unrecognized option "--http:8089"
uwsgi: unrecognized option "--http:8089" getopt_long() error
參數(shù)格式不對 :8089前面要加空格 uwsgi還在開啟
uwsgi: unrecognized option "--http"
(venv) [root@localhost TrackManagement]# uwsgi --http:8089 --module TrackManagement.wsgi uwsgi: unrecognized option "--http" getopt_long() error
uwsgi還在開啟 先殺了進(jìn)程再重啟
uwsgi trkMngm_uwsgi.ini -> invalid request block size: 21573 (max 4096)...skip
啟動了之后每次訪問
*** Stats server enabled on 127.0.0.1:9295 fd: 12 *** invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip invalid request block size: 21573 (max 4096)...skip
trkMngm_uwsgi.ini 文件中有設(shè)置nginx的socket
如果這時(shí)候nginx沒有對應(yīng)的配置或者配置了但是nginx沒有重啟
就會產(chǎn)生這個(gè)錯(cuò)誤
ModuleNotFoundError: No module named "TrackManagement/TrackManagement/wsgi"
(venv) [root@localhost TrackManagement]# uwsgi --http :8089 --module TrackManagement/TrackManagement/wsgi.py *** Starting uWSGI 2.0.18 (64bit) on [Tue Feb 19 11:33:20 2019] *** compiled with version: 4.8.5 20150623 (Red Hat 4.8.5-36) on 18 February 2019 05:28:03 os: Linux-3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 nodename: localhost.localdomain machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 4 current working directory: /root/Odin/TrackManagement detected binary path: /root/Odin/TrackManagement/venv/bin/uwsgi uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 63229 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uWSGI http bound on :8089 fd 4 spawned uWSGI http 1 (pid: 33181) uwsgi socket 0 bound to TCP address 127.0.0.1:33454 (port auto-assigned) fd 3 uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** Python version: 3.6.4 (default, Mar 6 2018, 13:19:57) [GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0x12acbf0 uWSGI running as root, you can use --uid/--gid/--chroot options *** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 72920 bytes (71 KB) for 1 cores *** Operational MODE: single process *** ModuleNotFoundError: No module named "TrackManagement/TrackManagement/wsgi" unable to load app 0 (mountpoint="") (callable not found or import error) *** no app loaded. going in full dynamic mode *** 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: 33180, cores: 1)
(venv) [root@localhost TrackManagement]# ls db.sqlite3 manage.py testUwsgi.py TrackManagement
runserver運(yùn)行django error : Bad Request
(venv) [root@localhost TrackManagement]# python manage.py runserver 0.0.0.0:8080 Performing system checks... System check identified no issues (0 silenced). You have 15 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run "python manage.py migrate" to apply them. February 18, 2019 - 07:47:25 Django version 2.1.7, using settings "TrackManagement.settings" Starting development server at http://0.0.0.0:8080/ Quit the server with CONTROL-C. Invalid HTTP_HOST header: "10.41.95.85:8080". You may need to add "10.41.95.85" to ALLOWED_HOSTS. Bad Request: / [18/Feb/2019 07:47:51] "GET / HTTP/1.1" 400 60826 Invalid HTTP_HOST header: "10.41.95.85:8080". You may need to add "10.41.95.85" to ALLOWED_HOSTS. Bad Request: /favicon.ico [18/Feb/2019 07:47:54] "GET /favicon.ico HTTP/1.1" 400 60906
django setting.py
ALLOWED_HOSTS = ["*"] -> ALLOWED_HOSTS = ["*"]
manage.py語法錯(cuò)誤
SyntaxError: invalid syntax [root@localhost TrackManagement]# python manage.py runserver 0.0.0.0:8080 File "manage.py", line 14 ) from exc
沒有運(yùn)行虛擬環(huán)境 外面的環(huán)境是python 虛擬環(huán)境才是python3 所以會有語法錯(cuò)誤
文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/40339.html
摘要:什么是接口測試全稱接口是一個(gè)位于復(fù)雜系統(tǒng)之上能簡化任務(wù),像中間人一樣不需要你了解詳細(xì)的所有細(xì)節(jié)。接口測試與性能測試之間存在接口性能測試,主要通過來進(jìn)行壓測。 很多小...
摘要:樹形控件數(shù)據(jù)格式組件最近做了第一個(gè)組內(nèi)可以使用的組件,雖然是最簡版,也廢了不少力。讓我來記錄這個(gè)樹形組件的編寫過程和期間用到的知識點(diǎn)。 vue+element tree(樹形控件數(shù)據(jù)格式)組件(1), 最近做了第一個(gè)組內(nèi)可以使用的組件,雖然是最簡版,也廢了不少力。各位前輩幫我解決問題,才勉強(qiáng)搞定。讓我來記錄這個(gè)樹形組件的編寫過程和期間用到的知識點(diǎn)。 首先說說需求,就是點(diǎn)擊出現(xiàn)彈窗+蒙板...
摘要:樹形控件數(shù)據(jù)格式組件最近做了第一個(gè)組內(nèi)可以使用的組件,雖然是最簡版,也廢了不少力。讓我來記錄這個(gè)樹形組件的編寫過程和期間用到的知識點(diǎn)。 vue+element tree(樹形控件數(shù)據(jù)格式)組件(1), 最近做了第一個(gè)組內(nèi)可以使用的組件,雖然是最簡版,也廢了不少力。各位前輩幫我解決問題,才勉強(qiáng)搞定。讓我來記錄這個(gè)樹形組件的編寫過程和期間用到的知識點(diǎn)。 首先說說需求,就是點(diǎn)擊出現(xiàn)彈窗+蒙板...
摘要:只需要填寫測試的參數(shù)值,點(diǎn)擊下方運(yùn)行按鈕,即可發(fā)起一次接口請求,請求結(jié)果將會在下方顯示出來保存歷史在接口測試界面,在進(jìn)行接口測試后點(diǎn)擊下方保存按鈕將會把本次測試數(shù)據(jù)接口,測試參數(shù)等信息保存下來。 《API管理平臺XXL-API》 一、簡介 1.1 概述 XXL-API是一個(gè)簡潔易用API管理平臺,提供API的管理、文檔、Mock和測試等功能。現(xiàn)已開放源代碼,開箱即用。 1.2 特性 ...
閱讀 2222·2021-09-30 09:47
閱讀 980·2021-08-27 13:01
閱讀 2968·2019-08-30 15:54
閱讀 3693·2019-08-30 15:53
閱讀 834·2019-08-29 14:07
閱讀 721·2019-08-28 18:16
閱讀 806·2019-08-26 18:37
閱讀 1415·2019-08-26 13:27