介绍


在腾讯云实验室接触到这个,Firekylin开源博客项目的完整部署方案。挺有意思,在测试服务器上做了一遍之后,又在自己的服务器上部署了一下,确认无误。这里总结一下步骤,相关配置不做进一步的解释说明。有兴趣的朋友可以尝试一下!

更详细的教程:https://cloud.tencent.com/developer/labs/lab/10094

 

 

Linux版本  

CentOS 7.5 64bit

[root@VM_16_8_centos ~]# uname -a
Linux VM_16_8_centos 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux


环境搭建   

Linux + Node.js + MySQL + Nginx

1.yum安装Node.js
一种脚本语言,是web开发的主流语言之一。

[root@VM_16_8_centos ~]# curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
[root@VM_16_8_centos ~]# yum -y install nodejs

2.使用 NPM 安装 PM2
PM2是 Node.js 的一个进程管理模块。

[root@VM_16_8_centos ~]# npm install pm2 -g

3.安装MySQL
yum方式安装

[root@VM_16_8_centos ~]# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
[root@VM_16_8_centos ~]# rpm -ivh mysql-community-release-el7-5.noarch.rpm
[root@VM_16_8_centos ~]# yum install mysql-community-server -y

ps:安装过程会比较慢,请耐心等待...

启动mysql

[root@VM_16_8_centos ~]# service mysqld restart

设置mysql账户密码

[root@VM_16_8_centos ~]# /usr/bin/mysqladmin -u root password '123'

4.安装Nginx

[root@VM_16_8_centos ~]# yum install nginx -y

 

 

安装并配置Firekylin项目


1.安装 Firekylin并解压

[root@VM_16_8_centos ~]# wget https://firekylin.org/release/latest.tar.gz
[root@VM_16_8_centos ~]# tar zvxf latest.tar.gz

2.安装依赖

[root@VM_16_8_centos ~]# cd firekylin
[root@VM_16_8_centos firekylin]# npm install

3.修改项目配置
将cwd 配置值为项目的当前项目路径 /root/firekylin

[root@VM_16_8_centos firekylin]# cp pm2_default.json pm2.json
[root@VM_16_8_centos firekylin]# vim pm2.json
{
  "apps": [{
    "name": "firekylin",
    "script": "www/production.js",
    "cwd": "/root/firekylin",
    "exec_mode": "fork",
    "max_memory_restart": "1G",
    "autorestart": true,
    "node_args": [],
    "args": [],
    "env": {

    }
  }]
}

4.启动项目

[root@VM_16_8_centos firekylin]# pm2 startOrReload pm2.json

这时候,就可以通过 http://<您的 CVM IP 地址>:8360/ 来访问web项目了。
根据之前的配置:

数据库账号:root            主机:127.0.0.1
数据库密码:123            默认
数据库名:firekylin        默认

后台账号: admin         后台密码: Password4Admin (自己设定)

转到登录

 

填写刚才设置的后台账号密码,进入后台管理页面


但先不要急使用,再配置一下Nginx

 

配置Nginx


1.复制项目下的nginx配置文件

[root@VM_16_8_centos firekylin]# cp nginx_default.conf nginx.conf
[root@VM_16_8_centos firekylin]# vim nginx.conf

    server_name www.benmoom.club;#其他不变,server_name指令后面添加自己的域名(没有跳过)

 

2.链接nginx.conf文件到Nginx配置目录下

[root@VM_16_8_centos firekylin]# ln -s /root/firekylin/nginx.conf /etc/nginx/conf.d/firekylin.conf

3.重启nginx服务

[root@VM_16_8_centos firekylin]# service nginx restart

 

直接访问域名进入前台界面