欢迎光临
我们一直在努力

Misskey:一个日产开源SNS系统

Misskey是一个基于Node.js的日产开源微博系统。

这套系统有两个非常亮眼的地方:

1.Misskey和Mastodon一样都是使用的Fediverse,所以Misskey可以与Mastodon等其他SNS平台互通,也就是说你可以跨平台交流。换句话说,Misskey也是一个“去中心化”的SNS平台。

2.Misskey的前端设计是真的太漂亮了,没图我说个J8:

个人资料页:

有兴趣可以去Misskey的官方实例注册个账号体验一下:https://misskey.xyz/

这么漂亮的妹纸(程序),不玩玩感觉亏了一个亿~

首先准备一下:

1.一台内存大于2GB的VPS,内存小于2G就别折腾了。
2.一个顶级域名已经解析到你的VPSIP,这个程序必须要用域名,并且强制SSL。

现在祭出烂大街的CentOS7X64,来走一波安装过程,首先更新一下系统:

yum -y update

EPEL源是肯定必不可少的啦:

yum -y install epel-release

开发工具包也走一走:

yum -y groupinstall "Development Tools"

基本组件装一装:

yum -y install wget git openssl-devel

Node.js搞一搞:

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
yum -y install nodejs

Redis也搞一下:

yum -y install redis

启动Redis并设置开鸡启动:

systemctl start redis
systemctl enable redis

Misskey使用Mongodb,所以现在先新建一个源:

vi /etc/yum.repos.d/mongodb-org-3.6.repo

写入:

[mongodb-org-3.6]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc

然后安装一下Mongodb

yum -y install mongodb-org

启动Mongodb并设置开机启动:

systemctl enable mongod.service
systemctl start mongod.service

创建数据库:

mongo
use misskey
db.users.save( {dummy:"dummy"} )
db.createUser( { user: "misskey", pwd: "password", roles: [ { role: "readWrite", db: "misskey" } ] } )
exit

注:password修改成一个你的高强度密码,确保数据安全。

现在拉取项目文件并进入项目目录:

git clone -b master git://github.com/syuilo/misskey.git
cd misskey

检查最新版本:

git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)

安装项目所需依赖:

npm install

复制一份配置文件并编辑:

cp .config/example.yml .config/default.yml
vi .config/default.yml

在这个配置内,你至少应该修改如下选项:

name: example-instance-name # Name of your instance
description: example-description # Description of your instance

maintainer:
  name: example-maitainer-name # Your name
  url: http://example.com/ # Your contact (http or mailto)

# Final accessible URL seen by a user.
url: https://example.tld/

# port: 3000    # A port that your Misskey server should listen.

mongodb:
  host: localhost
  port: 27017
  db: misskey
  user: example-misskey-user
  pass: example-misskey-pass

redis:
  host: localhost
  port: 6379
  pass: example-pass

其中url的地址必须是https,port前面的#号注释要去掉,redis的pass修改成null。

编辑好了之后安装node-gyp:

npm install -g node-gyp

继续使用node-gyp安装项目所需依赖:

node-gyp configure
node-gyp build

开始构建:

NODE_ENV=production npm run build

完成之后,新建一个系统服务:

vi /etc/systemd/system/misskey.service

写入:

[Unit]
Description=Misskey daemon

[Service]
Type=simple
User=root
ExecStart=/usr/bin/npm start
WorkingDirectory=/root/misskey
TimeoutSec=60
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=misskey
Restart=always
Environment=NODE_ENV=production

[Install]
WantedBy=multi-user.target

现在我们就可以用systemd来启动Misskey了:

systemctl enable misskey
systemctl start misskey

现在我们关闭防火墙和SELinux:

systemctl stop firewalld.service
systemctl disable firewalld.service
vi /etc/selinux/config
SELINUX=disabled
setenforce 0

安装Certbot:

yum -y install certbot

使用Certbot签发域名证书(example.com换成你的域名):

certbot certonly --standalone -d example.com

签发成功之后,证书路径:

/etc/letsencrypt/live/example.com/fullchain.pem
/etc/letsencrypt/live/example.com/privkey.pem

现在安装Nginx用于反向代理,新建一个源:

vi /etc/yum.repos.d/nginx.repo

写入:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1

然后yum搞一下:

yum -y install nginx

现在新建一个站点配置文件:

vi /etc/nginx/conf.d/example.com.conf

写入:

map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

server {
    listen       80;
    listen       443 ssl http2;
    server_name  example.com www.example.com;
    client_max_body_size 100m;
    client_body_buffer_size 2048k;
    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }

    ssl_certificate    /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key    /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    error_page 497  https://$host$request_uri;

location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header Proxy "";
    proxy_pass_header Server;

    proxy_pass http://127.0.0.1:3000;
    proxy_buffering off;
    proxy_redirect off;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;

    tcp_nodelay on;
  }
}

接着修改Nginx主配置文件:

vi /etc/nginx/nginx.conf

修改第一行nginx的运行用户为root:

user  root;

最后启动Nginx:

systemctl start nginx

现在,打开你的站点域名,你应该可以看到一个Misskey的实例了。现在你应该注册一个账号,接着回到终端内。

把你的账号设置为管理员:

node cli/mark-admin @[email protected]

本文参考文献:

https://github.com/syuilo/misskey/blob/develop/docs/setup.ja.md

https://github.com/syuilo/misskey/blob/develop/docs/manage.ja.md

赞(0)
未经允许不得转载:拆东墙 » Misskey:一个日产开源SNS系统

评论 抢沙发

登录

找回密码

注册