开源Icarus论坛部署详细过程

Icarus部署详细过程

论坛效果图

开源Icarus论坛部署详细过程

环境部署

python3.6

下载适当的ubuntu系统作为底层部署系统:

docker pull ubuntu:latest

配置ubuntu源:

add-apt-repository ppa:deadsnakes/ppa
这时如有报错,报错信息如下:
add-apt-repository command not found – Debian & Ubuntu

解决方法:

add-apt-repository command not found – Debian & Ubuntu – Quick Fix

这里我使用的ubuntu系统是18.04的,信息如下:

# cat /etc/issue
Ubuntu 18.04.1 LTS \n \l

使用下面命令即可:

apt-get install -y software-properties-common

然后:

add-apt-repository ppa:deadsnakes/ppa
apt-get update
apt-get install -y python3.6 python3.6-dev python3.6-venv
sh -c "curl https://bootstrap.pypa.io/get-pip.py | python3.6"

出现问题:

ubuntu ImportError: cannot import name 'sysconfig'

解决方法:

# apt-get install python3-distutils

再次:

sh -c "curl https://bootstrap.pypa.io/get-pip.py | python3.6"

NodeJS

# apt-get install -y nodejs
# nodejs --version
v8.10.0

PostgreSQL

postgresql安装与使用参考文档:

安装postgresql

apt install postgresql-10

启动postgresql服务:

# service postgresql start 
# service postgresql status

装好之后做一些配置:

su postgres
createdb icarus
createuser icarus
psql
# 进入 PQ Shell
GRANT ALL ON DATABASE icarus TO icarus;
ALTER USER icarus WITH PASSWORD 'IcaruStest123';
postgres-# \q

Redis

安装redis:

apt-get install -y redis

启动redis

redis-server &

后端篇

建议使用 pipenv 进行部署。

配置国内源:

cd /
git clone https://github.com/fy0/Icarus.git
cd /Icarus/backend
mkdir -p ~/.config/pip
echo -e '[global]\nindex-url = https://mirrors.ustc.edu.cn/pypi/web/simple\nformat = columns' > ~/.config/pip/pip.conf

pip安装pipenv:

pip3.6 install pipenv
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
pipenv install

环境装完之后,这样启动服务:

pipenv shell
python main.py

首次启动会生成private.py,并退出main.py进程,这个文件里的内容会覆盖 config.py 中的配置。如下:

Setting up private config...
/Icarus/backend/private.py generated.
Please edit private.py before run main.py next time.
Exited.

配置config.py文件

主要更改配置文件中的站点地址、平台维护人联系信息,邮箱信息设置

再次启动项目

python main.py

这时候如有报错,如slim模块没有安装,请先安装项目所需模块

pip install -r requirements.txt

如果没有slim==0.3.13,请将 requirements.txt 文件中 slim 那行注销掉,采用下面的方式安装slim:

git clone https://github.com/fy0/slim.git

# 执行如下命令
python setup.py build
python setup.py install

现在再再次启动项目脚本:

python main.py

前端篇

apt install -y npm
cd Icarus
npm install

在 Icarus 目录下新建一个 private.js:

// 单端口方案
var host = window.location.host;

export default {
    remote: {
        API_SERVER: '//' + host,
        WS_SERVER: 'ws://' + host + '/ws',
    },
    qiniu: {
        server: 'http://upload.qiniu.com',
        // host: '//test-bucket.myrpg.cn',
        suffix: 'normal'
    }
}

生成dist目录备用:

npm run build

扩展篇:Nginx部署

apt install -y nginx
cd Icarus
cp misc/nginx/icarus-1port.conf /etc/nginx/conf.d/

随后编辑 /etc/nginx/conf.d/icarus-1port.conf,将

# root /home/{user}/Icarus/dist;  ##修改为正确的路径

重启服务:

service nginx restart

写在最后

为了以后的部署方便和数据迁移,我制作了镜像,后续我会把镜像上传至dockerhub上。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章