代码打包
Nodejs打包
// 全局安装pkg打包工具
npm i -g pkg
// pkg 打包选择入口js即可
pkg index.js
// 打包后会有以下三个文件
// 将内容复制到linux中待使用
Vue打包
npm run build
// 打包出来的dist目录整体上传到服务器备用
环境安装
redis
// 检查是否有yum源,一般没有
yum install redis
// 解决上一条问题
yum install epel-release -y
// 再次安装
yum install redis -y
// 设置开机自启动
chkconfig redis on
// 启动服务
service redis start
// 不放心的可以查看状态
service redis status
MySQL
// 下载源并安装
// !! 这里有可能报没有wget命令,yum install wget -y 即可解决
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
yum localinstall mysql57-community-release-el7-11.noarch.rpm
// 检查源安装情况
yum repolist enabled | grep “mysql.-community.”
// 安装
yum install mysql-community-server -y
// 如果出现以下报错
Public key for mysql-community-common-5.7.38-1.el7.x86_64.rpm is not installed
// 解决方法
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
// 设置开机自启动
systemctl enable mysqld
systemctl daemon-reload
// 启动
systemctl start mysqld
// 查看状态
systemctl status mysqld
// 获取MySQL的初始化密码
grep ‘temporary password’ /var/log/mysqld.log
// 登陆进去
mysql -uroot -p
// 重新设置MySQL密码
set password for ‘root’@‘localhost’=password(‘Root1234!’);
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会报错。
// exit 退出并刷新服务
systemctl restart mysqld
// 添加个外部可用账户不建议使用root
GRANT ALL PRIVILEGES ON . TO ‘touchfish’@‘%’ IDENTIFIED BY ‘Touchfish1234!’ WITH GRANT OPTION;
// 给root设置的方法
#使用mysql数据库
use mysql;
#查询host值:
select user,host from user;
#%号表示允许任意主机连接
#如果没有"%"这个host值,就执行下面:
update user set host='%' where user='root';
#再次查询
select user,host from user;
#使之生效
flush privileges;
// 修改默认编码,修改/etc/my.cnf配置文件
[mysqld]
character_set_server = utf8
init_connect=‘SET NAMES utf8’
// 重启服务
systemctl restart mysqld
// 如果使用的是虚拟机且navcat一直报错:重启虚拟机即可
2003-Can’t connect to MySQL server on ‘192.168.0.105’(10060"Unknown error")
Nginx
// 安装
yum -y install nginx
// 开机自启动
systemctl enable nginx
// 启动服务
service nginx start
// 默认配置目录在 /etc/nginx
// 默认服务文件夹在 /usr/share/nginx/html
至于后面nginx放dist目录文件然后代理到node即可
Q.E.D.