Centos部属前后端项目
一、安装python3
# 下载并解压
cd /opt
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
tar -zxf Python-3.6.3.tgz # 编译安装
cd Python-3.6.3/
./configure --prefix=/opt/python3/
make && make install
二、下载node并解压
wget https://nodejs.org/dist/v10.15.0/node-v10.15.0-linux-x64.tar.xz
tar -xJf node-v10.15.0-linux-x64.tar.xz
三、添加环境变量
vim /etc/profile # 在文件的末尾添加
PATH=/opt/python3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/node-v10.15.0-linux-x64/bin # 保存退出,加载文件
source /etc/profile
四、安装虚拟环境工具virtualenvwrapper
pip3 install virtualenvwrapper vim ~/.bashrc
# 添加以下代码 WORKON_HOME=~/Envs
VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
VIRTUALENVWRAPPER_PYTHON=/opt/python3/bin/python3
source /opt/python3/bin/virtualenvwrapper.sh # 保存,然后重新登陆
五、源码安装redis
cd /opt/
wget http://download.redis.io/releases/redis-4.0.12.tar.gz
tar -zxf redis-4.0.12.tar.gz
make && make install # 创建配置文件
vim /etc/redis.conf # 输入以下代码
port 6379
daemonize yes
protected-mode yes # 启动
redis-server /etc/redis.conf
六、部署前端
[root@localhost luffy_boy]# cd /opt/luffy/07-luffy_project_01/
[root@localhost 07-luffy_project_01]# ls
build dist node_modules package-lock.json src
config index.html package.json README.md static # 默认根据目录中的package.json安装相应的模块,生成node_modules文件夹
npm install # 替换向后端发送请求的URL接口 # 打包vue项目,生成一个dist的静态文件夹(注意内存,内存不足会打包失败)
npm run build
七、部署后端
# 1.进入虚拟环境
# 2.安装对应的模块
pip3 install requirements.txt # 3.进入项目的目录
# 4.创建uwsgi.ini
vim uwsgi.ini '''编写以下配置'''
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /opt/luffy/luffy_boy
# Django's wsgi file
module = luffy_boy.wsgi
# the virtualenv (full path)
home = /root/Envs/luffy
# 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:9000
#http =0.0.0.0:9000
# clear environment on exit
vacuum = true
#后台运行uwsgi
#daemonize=yes # 5.测试运行
uwsgi --ini uwsgi.ini
八、nginx的配置
# 1.修改nginx的配置文件 server {
listen 80;
server_name 192.168.11.169;
location / {
root /opt/luffy/07-luffy_project_01/dist;
index index.html index.htm;
}
} server {
listen 8000;
server_name 192.168.11.169;
# 反向代理
location /{
uwsgi_pass 0.0.0.0:9000;
include /opt/nginx/conf/uwsgi_params;
}
} # 启动nginx
/opt/nginx/sbin/nginx
九、安装并使用supervisor管理后端项目
# 1.退出虚拟环境
# 2.安装supervisor
easy_install supervisor # 3.通过命令生成supervisor的生成配置文件
echo_supervisord_conf > /etc/supervisor.conf # 4.修改配置文件
vim /etc/supervisor.conf '''在末尾添加以下代码'''
[program:luffy]
command=/root/Envs/luffy/bin/uwsgi /opt/luffy/luffy_boy/uwsgi.ini
stopasgroup=true
killasgroup=true # 5.保存退出,启动supervisor
supervisord -c /etc/supervisor.conf # 6.请求后端项目
supervisorctl -c /etc/supervisor.conf start all
部署完成!!!
Centos部属前后端项目的更多相关文章
- Docker 部署前后端项目
Docker 部署前后端项目 平生不会相思,才会相思,便害相思. 简介:都是被逼的,从零开始一个Docker 部署九个微服务和三个前端项目.其中,这些服务需要用到Nacos.MySQL.Nginx.E ...
- 在IDEA中使用Maven将SpringBoot项目打成jar包、同时运行打成的jar包(前后端项目分离)
1.maven教程官网 https://m.runoob.com/maven/ 2.理解Maven的构建生命周期(clean.Package) 3.在项目中使用maven进行打包 4.运行打包好的ja ...
- vue+django前后端项目部署
一.python3的安装 1.安装python前的库环境: yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel ...
- 【宝塔面板】centOS部署前后端分离所有遇到的坑,Django
1:刚刚买完服务器,在宝塔面板安装完一切工具,Django顺利运行后(不能运行一般是起了中文名) # 问题:想迁移数据库,结果发现-bash: python3: command not found# ...
- 测试开发【Mock平台】04实战:前后端项目初始化与登录鉴权实现
[Mock平台]为系列测试开发教程,从0到1编码带你一步步使用Spring Boot 和 Antd React 框架完成搭建一个测试工具平台,希望作为一个实战项目能为你的测试开发学习有帮助. 一.后端 ...
- spring boot+vue前后端项目的分离(我的第一个前后端分离项目)
文章目录 1.前端vue的搭建 2.后端项目的构建 pom文件中引入的jar包 yml文件用来配置连接数据库和端口的设置 application.property进行一些整合 controller层( ...
- Docker部署前后端项目
本地(ubuntu19.04)安装docker: sudo apt install docker.io SSH连接服务器: 安装Docker: yum update yum -y install do ...
- 简述前后端项目RSA+AES加解密
一.登录机制 在项目中,我们可以大致得出一个登录的过程,主要分为 登录验证.登录保持.退出三个部分.登录验证是指客户端提供用户名和密码,向服务器提出登录请求,服务器判断客户端是否可以登录并向客户端确 ...
- LNMP环境+ 前后端项目部署+redis+redis扩展
LNMP 环境 (参照https://lnmp.org/install.html) wget -c http://soft.vpser.net/lnmp/lnmp1.4.tar.gz & ...
随机推荐
- ASP程序加密/解密方法大揭密
如今,用ASP技术构建的网站随处可见.由于ASP脚本是在服务器上解释执行的(无法编译),因此你辛苦开发出来的ASP代码,很容易被人拷去任意修改,如何保护ASP源代码呢?这是每个ASP站长都会遇到的 ...
- 暚光科技定位系统数据解析-java
暚光科技定位系统数据解析-java package com.ygkj.test; import java.io.DataInputStream; import java.io.IOException; ...
- osg指定向量旋转指定角度
向量AB,沿着n旋转10度 osg::Vec3 left = AB*osg::Matrix::rotate(osg::inDegrees(10), n); osg::Vec3 right = AB*o ...
- boost中g++ 链接undefined reference to `boost::system::generic_category()问题
编译错误如下: g++ -std=c++11 tcp_session.cpp tcp_server.cpp test.cpp -o test -pthread/tmp/ccv4rZkD.o: In ...
- php composer 报错 requires php ^7.1.8 || ^8.0 -> your php version
php 环境变量版本低于7.1.8,更新php环境变量版本
- 上传base64图片并压缩
elementUI+react 布局 <Dialog title="充值" visible={ dialogVisible } onCancel={ () => thi ...
- python-机器学习-深度学习-算法-面试题
GitHub 地址: https://github.com/taizilongxu/interview_python https://github.com/imhuay/Algorithm_Inter ...
- [LeetCode] 188. Best Time to Buy and Sell Stock IV 买卖股票的最佳时间 IV
Say you have an array for which the ith element is the price of a given stock on day i. Design an al ...
- [LeetCode] 229. Majority Element II 多数元素 II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times. Note: The a ...
- logrotate 切割日志
在工作中需要切割日志我们项目中选择的系统自带的logrotate,如需要其他需求需要自己在百度一下或者参考: https://www.cnblogs.com/kevingrace/p/6307298. ...