1.安裝css
yum install mariadb-server mariadb -y
2.經過yum安裝的軟件,怎麼啓動html
systemctl start/stop/status/restart mariadb
3.登陸數據庫vue
mysql
4.導出windows的數據庫,導入到linuxnode
導出命令 mysqldump -uroot -p crm > crm.sql # 指定數據庫導出到crm.sql數據文件中 傳輸到linux中,進行導入 簡單的利用 lrzsz工具傳輸 或者下載xftp工具 導入數據的命令 方式1: 1.建立一個crm數據庫 create database crm; # 導入數據的命令 mysql -uroot -p crm < crm.sql #指定crm數據庫,導入一個sql文件 方式2: 登錄數據庫以後,用命令導入數據 1.建立一個crm數據庫 create database se_crm; 2.切換數據庫 use crm; 3.讀取sql文件,寫入數據集 mareiadb> source /opt/crm.sql;
1.編譯安裝python3,解決環境變量python
2.下載virtualenvwrapper工具mysql
3.使用mkvirtualenv命令,建立新的虛擬環境,用於啓動crmlinux
mkvirtualenv crm
4.拷貝crm項目代碼到linux機器ios
5.解決crm項目運行所需的依賴環境nginx
方式一: pip3 install -i https://pypi.douban.com/simple django==1.11.23 pip3 install -i https://pypi.douban.com/simple pymysql pip3 install -i https://pypi.douban.com/simple django-multiselectfield 方式二: 導出python解釋器模塊的命令 pip3 freeze > requirements.txt # requirements.txt文件是python程序員公認的模塊依賴文件 安裝這個requirements.txt文件中全部的模塊 pip3 install -r requirements.txt # 指定依賴文件安裝,讀取文件中全部的模塊信息
1.經過pip3安裝程序員
pip3 install -i https://pypi.douban.com/simple uwsgi
2.經過uwsgi命令去啓動django
啓動方式一:
uwsgi --http :8000 --module 項目名.wsgi --http指定http協議啓動socket服務端,能夠經過瀏覽器直接訪問 --module 是找到crm項目第二級目錄下的wsgi.py 文件 uwsgi --http :8000 --module crm.wsgi
啓動方式二:
1.建立配置文件 touch uwsgi.ini 2.寫入以下內容 uwsgi.ini內容以下 [uwsgi] # Django-related settings # the base directory (full path) # 填寫crm項目的絕對路徑,第一層 chdir = /opt/CRM # Django's wsgi file #填寫crm項目第二層目錄中的wsgi文件 module = CRM.wsgi # the virtualenv (full path) #填寫解釋器的安裝絕對路徑(虛擬環境) home = /root/Virs/crm # process-related settings # master master = true # maximum number of worker processes #指定uwsgi的多進程數量,指定爲cpu的核數便可(填cpu的4倍數量) processes = 4 # the socket (use the full path to be safe #指定crm啓動的協議,當你和nginx結合進行反向代理,就用unix-socket協議 ,這種方式沒法直接訪問,只能經過nginx反代 socket = 0.0.0.0:8000 #指定http協議啓動,不安全,沒有意義,只是本身調試使用 #http = 0.0.0.0:8000 # ... with appropriate permissions - may be needed # chmod-socket = 664 # clear environment on exit vacuum = true # 後臺運行uwsgi daemonize=yes 3.收集django的全部靜態文件,交給nginx處理 打開 django的settings.py,修改成以下行 STATIC_ROOT='/opt/crm/crmstatic' # 加上這個參數就好了 STATIC_URL = '/static/' STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'static') ] 經過命令收集django的全部靜態文件 python3 manage.py collectstatic 4.指定uwsgi.ini配置文件啓動 uwsgi --ini uwsgi.ini # 參數 --ini是指定文件的意思
1.安裝nginx
2.修改配置文件nginx.conf
注意server{}多虛擬主機是自上而下的加載順序 所以修改第一個server{}虛擬主機,修改成以下反代的寫法 且添加nginx處理django的靜態文件方式 server { #nginx監聽的地址 listen 80; #定義網站的域名 server_name _; #charset koi8-r; #nginx的url匹配 , /這個斜槓就表明這樣的請求: 192.168.13.117:85/ #這個是最低級匹配,全部的請求都會進入location,進行處理 #比如 http://192.168.13.117/crm/login/ location / { #基於uwsgi協議的請求轉發,給後端django的啓動地址 uwsgi_pass 0.0.0.0:8000; #這個是請求轉發 include uwsgi_params; #這個是添加一個文件,添加請起頭信息的 } #當之後請求是從static開始,我就讓他去這個目錄去找 #http://192.168.13.117/static/css/reset.css #不加斜槓 location /static { alias /opt/crm/crmstatic; } }
端口配置:
uwsgi部署drm項目使用端口: 8002
nginx部署vue項目使用端口: 85
nginx監聽vue請問端口: 8001
1.首先須要安裝nodejs環境
經過yum安裝 下載編譯安裝 修改環境變量 測試node和npm的版本
2.安裝項目所需node模塊,打包node項目
1.進入vue源碼目錄,安裝package.json的模塊內容 npm install 注意事項: 此時注意,本地寫的vue代碼,接口極可能鏈接的服務器地址有問題,注意Axios.POST提交的地址,必定要發送給django應用(若是用了nginx,就發送給nginx的入口端口) 確保vue的route模式是history 2.準備編譯打包vue項目,替換配置文件全部地址,改成服務器地址 注意端口號,如需替換端口號,/舊ip:端口/新ip:端口/ sed -i 's/127.0.0.1/122.51.103.227/g' /vue項目路徑/src/restful/api.js 3.打包vue項目,生成一個dist靜態文件夾 npm run build 4.檢查dist文件夾 index.html static
3.配置nginx
server { # 用戶訪問域名或者ip,默認是nginx的80端口 listen 80; server_name _; location / { root /項目路徑/dist; index index.html; } }
1.建立虛擬環境,在虛擬環境下安裝項目所需依賴模塊,數據庫等
能夠從項目中導出所需依賴模塊 pip freeze > requirements.txt 在Linux中安裝 pip install -r requirements.txt 前面說了mysql,這裏說一下redis的安裝 yum install redis -y systemctl start redis 驗證登錄redis [root@linux ~]# redis-cli 127.0.0.1:6379> ping PONG
2.經過uwsgi啓動drf項目
在drf項目第一次目錄中建立 touch uwsgi.ini 修改此文件 [uwsgi] # Django-related settings # the base directory (full path) chdir = /項目第一層目錄的路徑 # Django's wsgi file module = 項目名.wsgi # the virtualenv (full path) home = /虛擬環境的路徑 # process-related settings # master master = true # maximum number of worker processes processes = 1 # the socket (use the full path to be safe socket = 0.0.0.0:8002 # clear environment on exit vacuum = true # 後臺運行uwsgi daemonize = yes uwsgi --ini 項目路徑/uwsgi.ini
server { listen 80; server_name _; location / { root /vue項目路徑/dist; index index.html; # 這一條參數確保vue頁面刷新時候,不會出現404頁面 try_files $uri $uri/ /index.html; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } server { listen 8001; server_name _; location / { uwsgi_pass 0.0.0.0:8002; include uwsgi_params; } }