处理逻辑
1. 下载node.js解压并且添加环境变量2. 修改vue文件路径 改为Nginx代理服务器地址(端口)3. 安装node依赖 选用国内淘宝源
1 下载文件
wget https://files.cnblogs.com/files/pyyu/07-luffy_project_01.zip
2 解压缩
unzip 07-luffy_project_01.zip
3 配置 node.js 环境[二进制源码包]
1. 下载wget https://nodejs.org/dist/v14.18.1/node-v14.18.1-linux-x64.tar.xz2. 解压xz -d node-v14.18.1-linux-x64.tar.xztar -xvf node-v14.18.1-linux-x64.tar
4 添加环境变量并且刷新
1. 修改如下vim /etc/profilePATH="/opt/tengine233/sbin:/opt/python396/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/node-v14.18.1-linux-x64/bin"2. 刷新source /etc/profilenode -vv14.18.1npm -v6.14.15
5 修改配置文件 /s25luffy/src/restful/api.js
sed -i 's/127.0.0.1:8000/192.168.1.9:9000/g' api.js
6 安装 node 模块的依赖
# 进入指定目录cd /tmp/s25luffylsbuild config index.html node_modules package.json package-lock.json README.md src staticnpm --registry https://registry.npm.taobao.org install# 安装后提示npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})added 1136 packages from 654 contributors in 27.306s
7 构建
npm run build# 输出Build complete.Tip: built files are meant to be served over an HTTP server.Opening index.html over file:// won't work.
8 修改 nginx.conf 增加虚拟主机返回路飞页面
server {listen 9999;server_name localhost;charset utf-8;location / {root /tmp/s25luffy/dist;index index.html;}}
部署现状[前端缺后端逻辑代码]

9 准备环境
在 /tmp 目录下,下载解压
wget https://files.cnblogs.com/files/pyyu/luffy_boy.zip
解压
unzip luffy_boy.zip
创建虚拟环境
cd luffy_bloy
python3 -m venv s25_luffy
创建包依赖文件
依赖文件
certifi==2018.11.29chardet==3.0.4crypto==1.4.1Django==2.1.4django-redis==4.10.0django-rest-framework==0.1.0djangorestframework==3.9.0idna==2.8Naked==0.1.31pycrypto==2.6.1pytz==2018.7PyYAML==3.13redis==3.0.1requests==2.21.0shellescape==3.4.1urllib3==1.24.1uWSGI==2.0.17.1
创建依赖
cd /tmp/luffy_boy
vim requirements.txt
批量安装
pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
测试启动
python3 manage.py runserver
修改Nginx配置,设置转发
server {listen 9000;server_name localhost;charset utf-8;location / {uwsgi_pass 1:9005;include uwsgi_params;}}
创建并修改 uwsgi.ini
# Django-related settings# 填写CRM项目第一层绝对路径chdir = /tmp/luffy_boy# 填写 CRM 项目第二层相对路径,找到第二层目录下的wsgi.py# 这里写的不是路径,而是以上一个参数为相对,找到第二层目录下的wsgi.py文件module = luffy_boy.wsgi# 虚拟环境Python解释器路径home = /tmp/luffy_boy/s25_luffy# process-related settings# mastermaster = true# 推荐性能为 核数 * 2 + 1processes = 3#threads = 2# socket和Nginx结合部署 unix-socket参数,这里先临时暂停使用# the socket (use the full path to be safesocket = 0.0.0.0:9005# 线上部署不会使用http参数,对于后端不安全,使用socket连结是安全的,用Nginx反向代理去访问# 后端程序是运行在防火墙内部,外网无法直接访问# 临时使用http参数,便于浏览器直接调试# http = 0.0.0.0:10001# ... with appropriate permissions - may be needed# chmod-socket = 664# clear environment on exitvacuum = truepidfile=uwsgi.piddaemonize=uwsgi.log
配置 supervisord.conf
[program:Luffyvue]command=/tmp/luffy_boy/s25_luffy/bin/uwsgi --ini /tmp/luffy_boy/luffy_boy/uwsgi.iniautostart=true ; 在supervisord启动的时候也自动启动startsecs=10 ; 启动10秒后没有异常退出,就表示进程正常启动了,默认为1秒autorestart=true ; 程序退出后自动重启,可选值:[unexpected,true,false],默认为unexpected,表示进程意外杀死后才重启startretries=3 ; 启动失败自动重试次数,默认是3stopasgroup=false ;默认为false,进程被杀死时,是否向这个进程组发送stop信号,包括子进程killasgroup=false ;默认为false,向进程组发送kill信号,包括子进程stdout_logfile_maxbytes=20MB ; stdout 日志文件大小,默认50MBstdout_logfile=/tmp/luffyvue.out ; 需要用户新建该目录
关闭进程重新应用项目
supervisorctl -c /etc/supervisord.conf # 关闭uwsgi stop Blogps -ef | grep supervisord # 查看管理工具PID 关闭进程kill -9 11464
##supervisor 常用命令
一、开启命令supervisor的服务器端部分启动命令:sudo unlink /var/run/supervisor.socksupervisord -c /etc/supervisord.conf此时默认开启了所有服务supervisor的客户端部分命令:supervisorctl status 查看进程运行状态supervisorctl start 进程名 启动进程supervisorctl stop 进程名 关闭进程supervisorctl restart 进程名 重启进程supervisorctl update 重新载入配置文件supervisorctl shutdown 关闭supervisordsupervisorctl clear 进程名 清空进程日志supervisorctl 进入到交互模式下。使用help查看所有命令。start stop restart + all 表示启动,关闭,重启所有进程。二、关闭命令supervisorctl stop all先关闭supervisor服务之后再关闭supervisord服务
遇到的报错
unix:///tmp/supervisor.sock no such file
解决方案
/usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf #启动路径(luffyboy_env) [root@vvkt7whznuckhiz2-0723575 luffy_boy]# systemctl enable supervisordCreated symlink from /etc/systemd/system/multi-user.target.wants/supervisord.service to /usr/lib/systemd/system/supervisord.service.
Redis的安装
1 下载解压
cd opt
wget https://download.redis.io/releases/redis-6.2.6.tar.gz
tar -xvf redis-6.2.6.tar.gz
2 安装包依赖
yum -y install cpp binutils glibc glibc-kernheaders glibc-common glibc-devel gcc makeyum -y install centos-release-sclyum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutilsscl enable devtoolset-9 bashyum search systemd-develyum -y install systemd-devel.x86_64
编译安装
make USE_SYSTEMD=yes
cd src && make all
测试启动
cd redis-6.2.6/src
./redis-server
make PREFIX=/opt/redis install
cd src && make install
检查文件
ls /opt/redis/ls /opt/redis/bin/
复制服务配置文件并做如下修改
cd /opt/redis-6.2.6/utilscp systemd-redis_server.service /etc/systemd/system/redis_6379.servicevim /etc/systemd/system/redis_6379.service
配置文件如下
[Unit]Description=Redis data structure serverDocumentation=https://redis.io/documentation#Before=your_application.service another_example_application.service#AssertPathExists=/var/lib/redisWants=network-online.targetAfter=network-online.target[Service]#ExecStart=/usr/local/bin/redis-server --supervised systemd --daemonize no## Alternatively, have redis-server load a configuration file:ExecStart=/opt/redis/bin/redis-server /etc/redis/redis_6379.confExecStop=/opt/redis/bin/redis-cli -p 6379 shutdownLimitNOFILE=10032NoNewPrivileges=yes#OOMScoreAdjust=-900#PrivateTmp=yesType=notifyTimeoutStartSec=90TimeoutStopSec=90UMask=0077#User=redis#Group=redisWorkingDirectory=/var/lib/redis_6379[Install]WantedBy=multi-user.target
创建文件夹
cd /var/libmkdir redis_6379
cd /etcmkdir redis
拷贝配置文件
cd /opt/redis-6.2.6cp redis.conf /etc/redis/redis_6379.conf
编辑配置文件
vim redis_6379.conf
配置文件如下
################################## MODULES ###################################### Load modules at startup. If the server is not able to load modules# By default Redis does not run as a daemon. Use 'yes' if you need it.# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.# When Redis is supervised by upstart or systemd, this parameter has no impact.daemonize no# If you run Redis from upstart or systemd, Redis can interact with your# supervision tree. Options:# supervised no - no supervision interaction# supervised upstart - signal upstart by putting Redis into SIGSTOP mode# requires "expect stop" in your upstart job config# supervised autosupervised systemd# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET# on startup, and updating Redis status on a regular# basis.# supervised auto - detect upstart or systemd method based on# UPSTART_JOB or NOTIFY_SOCKET environment variables# Note: these supervision methods only signal "process is ready."# They do not enable continuous pings back to your supervisor.===============================================================================# Note that on modern Linux systems "/run/redis.pid" is more conforming# and should be used instead.pidfile /var/run/redis_6379.pidlogfile "/var/log/redis_6379.log"# Specify the server verbosity level.# This can be one of:# debug (a lot of information, useful for development/testing)# verbose (many rarely useful info, but not a mess like the debug level)# notice (moderately verbose, what you want in production probably)# warning (only very important / critical messages are logged)loglevel notice
测试启动
systemctl start redis_6379systemctl status redis_6379
设置环境变量
vim /etc/profilePATH="/opt/tengine233/sbin:/opt/python396/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/node-v14.18.1-linux-x64/bin:/opt/redis/bin"source /etc/profile
