1.前端vue部署前端
1 下載vue代碼,解壓縮vue
wget https://files.cnblogs.com/files/pyyu/07-luffy_project_01.zip
unzip 07-luffy_project_01.zip
2 配置node環境,去打包編譯vue代碼node
#下載node的代碼包 wget https://nodejs.org/download/release/v8.6.0/node-v8.6.0-linux-x64.tar.gz #解壓縮node代碼包 tar -zxvf node-v8.6.0-linux-x64.tar.gz #配置node的PATH環境變量便可,修改PATH生效便可
3 驗證node是否正確配置(node就如同python解釋器,npm如同pip軟件包管理工具)python
node -vmysql
npm -vlinux
4 修改vue的代碼文件nginx
#修改方式以下 # /opt/s18luffy/07-luffy_project_01/src/restful下找到api.js sed -i "s/127.0.0.1:8000/192.168.40.145:9000/g" api.js # sed是linux處理字符串的命令 -i是將結果替換到文件 # s是替換模式 g是全局替換
5 進行打包vue,生成靜態文件夾distredis
#確保你在vue的代碼文件夾下 npm install #解決vue代碼所需的模塊依賴 npm run build #進行編譯打包
6 當vue打包正確完成後,生成一個dist靜態文件夾,此時就能夠給nginx去處理了sql
2.後端uwsgi部署shell
1 下載路飛代碼
wget https://files.cnblogs.com/files/pyyu/luffy_boy.zip
2 安裝新的虛擬環境,解決環境依賴問題,能夠用requirements.txt解決依賴問題
mkvirtualenv s18luffy vim requirements.txt #打開,編輯寫入如下模塊依賴包信息 certifi==2018.11.29 chardet==3.0.4 crypto==1.4.1 Django==2.1.4 django-redis==4.10.0 django-rest-framework==0.1.0 djangorestframework==3.9.0 idna==2.8 Naked==0.1.31 pycrypto==2.6.1 pytz==2018.7 PyYAML==3.13 redis==3.0.1 requests==2.21.0 shellescape==3.4.1 urllib3==1.24.1 uWSGI==2.0.17.1
3 安裝這個文件 requirements.txt
pip3 install -i https://pypi.douban.com/simple -r requirements.txt
4 使用uwsgi啓動路飛學城後端
#使用uwsgi.ini配置文件方式啓動,內容以下 [uwsgi] # Django-related settings # the base directory (full path) chdir = /opt/s18luffy/luffy_boy # Django's wsgi file module = luffy_boy.wsgi # the virtualenv (full path) home = /root/Envs/s18luffy # process-related settings # master master = true # maximum number of worker processes processes = 4 # the socket (use the full path to be safe socket = 0.0.0.0:8001 # ... with appropriate permissions - may be needed # chmod-socket = 664 # clear environment on exit vacuum = true
5 用supervisor管理路飛的後臺
vim /etc/supervisor.conf #打開文件,在最底部寫入以下內容 [program:s18luffy] command=/root/Envs/s18luffy/bin/uwsgi --ini /opt/s18luffy/luffy_boy/uwsgi.ini stopasgroup=true killasgroup=true
3.nginx反向代理轉發以下
4.啓動mysql 以及redis
yum install redis -y systemctl start redis #啓動redis