Centos 7.4搭建Quick Reference缩略图
内容纲要

 

  • 准备工作:
  • 服务器:CentOS 7.4,1核CPU,2G内存,16G的ssd硬盘

一、CentOS7.4初始化

[root@localhost ~]# systemctl disable firewalld ## 开机自启为disable
[root@localhost ~]# systemctl stop firewalld ## 关闭firewalld
[root@localhost ~]# setenforce 0 ## 临时关闭selinux防火墙机制
[root@localhost ~]# swapoff -a ## 关闭所有已经打开的交换分区

二、配置yum仓库

[root@localhost ~]# rm -rf /etc/yum.repos.d/CentOS-Base.repo && curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo ## 从阿里云上下载Centos-7.repo文件

[root@localhost ~]# yum -y clean all && yum makecache && yum update ## 执行更新yum源

三、安装nodejs

[root@localhost ~]# yum -y install wget ## 安装wget
[root@localhost ~]# wget https://npm.taobao.org/mirrors/node/v14.15.1/node-v14.15.1-linux-x64.tar.gz
## 下载nodejs源码包
[root@localhost ~]# tar xf node-v14.15.1-linux-x64.tar.gz ## 解压nodejs源码包
[root@localhost ~]# mv node-v14.15.1-linux-x64 nodejs ## 将解压出来的源码包命名为nodejs
[root@localhost ~]# mv nodejs /usr/local ## 移动到/usr/local的目录下

[root@localhost ~]# yum -y install vim ## 安装vim工具
[root@localhost ~]# vim /etc/profile ## 编辑profile文件
## 在行尾添加以下两行,然后按:wq保存退出
export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH

[root@localhost ~]# source /etc/profile ## 执行/etc/profile
root@localhost ~]# node -v ## 查看node版本
v14.15.1
[root@localhost ~]# npm -v ## 查看npm版本
6.14.8

四、使用git克隆仓库

[root@localhost ~]# yum -y install git
[root@localhost ~]# git clone https://github.com/Fechin/reference.git ## 将文件克隆到本地

 

五、启动reference测试

[root@localhost ~]# npm install ## 执行本地安装
[root@localhost ~]# npm run dev ## 启动命令

六、开机自启脚本

[root@localhost ~]# vim /root/reference/.start.sh ## 创建隐藏启动脚本,并添加以下命令
nohup npm run dev >/dev/null 2>&1 & exit

[root@localhost ~]# vim /etc/rc.d/rc.local ## 编辑rc.local脚本
## 在末尾添加以下内容,然后按:wq保存退出
/root/reference.start.sh

[root@localhost ~]# chmod 777 /root/reference/.start.sh ## 给脚本可执行权限
[root@localhost ~]# reboot ## 重启后,就可以正常访问了

 

作者 IT大佬

在 “Centos 7.4搭建Quick Reference” 有 1 条评论

发表回复