一、查看當前工做路徑 wdw@VM-0-3-ubuntu:~$ pwd /home/wdw 二、在Ubuntu中建立項目文件夾: wdw@VM-0-3-ubuntu:~$ mkdir site wdw@VM-0-3-ubuntu:~$ cd site wdw@VM-0-3-ubuntu:~/site$ mkdir fwa wdw@VM-0-3-ubuntu:~/site$ cd fwa 三、再次查看當前工做路徑 wdw@VM-0-3-ubuntu:~/site/fwa$ pwd /home/wdw/site/fwa
wdw@VM-0-3-ubuntu:~/site/fwa$ virtualenv --python=python3 env wdw@VM-0-3-ubuntu:~/site/fwa$ source env/bin/activate
下載 (env) wdw@VM-0-3-ubuntu:~/site/fwa$ git clone https://github.com/davidwbnu/web_02.git 查看目錄結構 (env) wdw@VM-0-3-ubuntu:~/site/fwa$ ls env web_02
進入項目目錄: (env) wdw@VM-0-3-ubuntu:~/site/fwa$ cd web_02 安裝項目依賴: (env) wdw@VM-0-3-ubuntu:~/site/fwa/web_02$ pip install -r requirements.txt
虛擬環境下繼續運行 python manage.py collectstatic 命令收集靜態文件到setting.py指定的目錄下(本例爲 /home/wdw/site/fwa/web_02/collect_static):python
(env) wdw@VM-0-3-ubuntu:~/site/fwa/web_02$ python manage.py collectstatic
(env) wdw@VM-0-3-ubuntu:~/site/fwa/web_02$ python manage.py migrate
(env) wdw@VM-0-3-ubuntu:~/site/fwa/web_02$ python manage.py createsuperuser
一、安裝gunicorn (env) wdw@VM-0-3-ubuntu:~/site/fwa/web_02$ pip install gunicorn 二、啓動gunicorn服務,完成項目部署 (env) wdw@VM-0-3-ubuntu:~/site/fwa/web_02$ gunicorn -b 172.27.0.3:8080 web_02.wsgi:application 其中172.27.0.3爲騰訊雲提供服務器的內網IP,web_02爲存放wsgi.py或setting.py文件的文件夾。 三、此外 查詢gunicorn的進程 ps -ef|grep nginx 查詢結果: | |-grep,28284 --color=auto gunicorn | `-gunicorn,24869 /home/wdw/site/fwa/env/bin/gunicorn -w 4 -b 172.27.0.3:8001 w_02.wsgi:application | |-gunicorn,1394 /home/wdw/site/fwa/env/bin/gunicorn -w 4 -b 172.27.0.3:8001 w_02.wsgi:application | |-gunicorn,5803 /home/wdw/site/fwa/env/bin/gunicorn -w 4 -b 172.27.0.3:8001 w_02.wsgi:application | |-gunicorn,20100 /home/wdw/site/fwa/env/bin/gunicorn -w 4 -b 172.27.0.3:8001 w_02.wsgi:application | `-gunicorn,32543 /home/wdw/site/fwa/env/bin/gunicorn -w 4 -b 172.27.0.3:8001 w_02.wsgi:application 中止gunicorn進程 kill -9 24869
若是項目須要靜態文件,還須要對Nginx進行配置。在下一部份內容中介紹nginx