日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

阿里云 Centos7 部署 Django 项目

發布時間:2024/9/5 编程问答 36 如意码农
生活随笔 收集整理的這篇文章主要介紹了 阿里云 Centos7 部署 Django 项目 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
      1. 前期準備
        1. 阿里云服務器
        2. mysql數據庫
        3. 已經本地運行成功的項目
      2. 阿里云服務器的環境配置
        1. Git #代碼管理
        2. Gitlab #代碼托管,要求服務器內存不低于2G,我選擇放棄
        3. Mysql #連接數據庫
        4. Python3 #python項目的運行環境,默認為python2
          1. Django #項目環境
          2. Uwsgi #項目運行后訪問的相關的配置文件
        5. Virtualenv #創建虛擬python環境
        6. Nginx #配置項目運行轉發的相關配置
      3. 環境配置的詳細操作
        1. 更新軟件包并安裝可能用到的依賴
          1. yum update -y
          2. yum -y groupinstall "Development tools"
          3. yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel
        2. 安裝mysql
          1. 下載安裝包
            1. wget https://repo.mysql.com//mysql80-community-release-el7-3.noarch.rpm
          2. 安裝
            1. yum install mysql80-community-release-el7-3.noarch.rpm
            2. yum -y install mysql-community-server
          3. 啟動mysql并查看運行狀態
            1. systemctl start  mysqld.service
            2. systemctl status mysqld.service
        3. 安裝python3
          1. 下載
            1. cd /usr/local/
            2. wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
            3. tar -zxvf Python-3.6.6.tgz
          2. 編譯
            1. cd Python-3.6.6
            2. ./configure --prefix=/usr/local/python
          3. 安裝
            1. make
            2. make install
          4. 建立軟連接
            1. ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
            2. ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3
        4. 安裝virtualenv
          1. 安裝
            1. pip3 install virtualenv
          2. 建立軟連接
            1. ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv
        5. 創建文件目錄
          1. mkdir -p /data/env
          2. mkdir -p /data/wwwroot
        6. 創建環境
          1. cd /data/env
          2. virtualenv --python=/usr/bin/python3 hellofuture
        7. 啟動環境
          1. cd hellofuture/bin
          2. source activate
        8. 安裝第三方包
          1. pip3 install django
          2. pip3 install uwsgi
          3. ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
        9. 拉代碼
          1. cd /data/wwwroot
          2. git clone  https://gitlab.com/feizisy/hellofuture.git/
        10. 配置uwsgi
          1. cd /data/wwwroot/hellofuture
          2. touch hellofuture.xml
          3. vim hellofuture.xml
            1. <uwsgi>
            2. <socket>127.0.0.1:8001</socket><!-- 內部端口,自定義 -->
            3. <chdir>/data/wwwroot/hellofuture/</chdir><!-- 項目路徑 -->
            4. <module>hellofuture.wsgi</module>
            5. <processes>4</processes> <!-- 進程數 -->
            6. <daemonize>uwsgi.log</daemonize><!-- 日志文件 -->
            7. </uwsgi>
        11. 安裝/配置nginx
          1. cd home
          2. wget http://nginx.org/download/nginx-1.13.7.tar.gz
          3. tar -zxvf nginx-1.13.7.tar.gz
          4. cd nginx-1.13.7
          5. ./configure
          6. make
          7. make install
          8. cd /usr/local/nginx/conf
          9. cp nginx.conf nginx.conf.bak
          10. vim nginx.conf
          11. 配置nginx.conf
          12. cd ../sbin
          13. ./nginx -t
          14. ./nginx
        12. uwsgi配置
          1. cd /data/wwwroot/hellofuture/
          2. uwsgi -x hellofuture.xml
        13. 重啟nginx
          1. cd /usr/local/nginx/
          2. ./nginx -s reload
        14. 運行項目
          1. cd /data/wwwroot/hellofuture/
          2. python3 manage.py runserver 0.0.0.0:8001
        15. 本地訪問
          1. 公網IP:8001
    1. 本文參考:https://blog.csdn.net/u012516524/article/details/82154053

總結

以上是生活随笔為你收集整理的阿里云 Centos7 部署 Django 项目的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。