1.下载安装包
git clone https://github.com/meolu/walle-web.git
2.安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
3.安装python3
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
mkdir /usr/local/python3
tar -xf Python-3.7.3.tgz
cd Python-3.7.3
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
rm -rf /usr/bin/python
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip
ln -s /usr/local/python3/bin/python3 /usr/bin/python
4.修改yum配置文件
[root@admin ~]# cat /usr/bin/yum
#!/usr/bin/python2
[root@admin ~]# cat /usr/libexec/urlgrabber-ext-down
#! /usr/bin/python2
5.安装mysql
vi /etc/yum.repos.d/mysql-community.repo
[mysql58-community]
name=MySql5.7 community server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
yum clean all
yum makecache
rpm -qa|grep mariadb
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64
yum install -y mysql-community-server
systemctl start mysqld
grep 'temporary password' /var/log/mysqld.log
mysql -uroot -p
create database walle charset=utf8 collate utf8_general_ci;
grant all privileges on walle.* to walle@localhost identified by 'walle';
flush privileges;
6.修改主机名
hostnamectl set-hostname admin.walle-web.io
cat /etc/sysconfig/network
# Created by anaconda
HOSTNAME=admin.walle-web.io
[root@admin walle-web]# cat /etc/resolv.conf
# Generated by NetworkManager
search admin.walle-web.io
yum install epel-release -y
7.安装nginx
yum install nginx -y
egrep -v "^$|#" /etc/nginx/nginx.conf.default >/etc/nginx/nginx.conf
[root@admin ~]# cat /etc/nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include conf.d/*.conf;
}
cat /etc/nginx/conf.d/walle.conf
upstream webservers {
server admin.walle-web.io:5000 weight=1; #这个是walle项目的启动端口
}
server {
listen 80;
server_name admin.walle-web.io; # walle域名设置,这个域名设置比较重要,需要在walle的配置一致
access_log /var/log/nginx/walle.log combined;
index index.html index.htm index.php; # 日志目录
location / {
try_files $uri $uri/ /index.html;
add_header access-control-allow-origin *;
root /opt/walle-web/fe; # 前端代码已集成到walle-web,即walle-web/fe的绝对路径
}
location ^~ /api/ {
add_header access-control-allow-origin *;
proxy_pass http://admin.walle-web.io:5000; #http://webservers;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Origin $host:$server_port;
proxy_set_header Referer $host:$server_port;
}
location ^~ /socket.io/ {
add_header access-control-allow-origin *;
proxy_pass http://admin.walle-web.io:5000;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Origin $host:$server_port;
proxy_set_header Referer $host:$server_port;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
# WebScoket Support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
systemctl restart nginx
systemctl status nginx
9.配置walle配置文件
[root@admin walle-web]# cat requirements/prod.txt
# Everything needed in production
fabric2==2.3.1
eventlet==0.23.0
gevent==1.3.7
gevent-websocket==0.10.1
# Flask
Flask==1.0.2
MarkupSafe==1.1.1
Werkzeug==0.15.3
Jinja2==2.10
Flask-RESTful==0.3.5
Flask-Babel==0.11.2
Flask-Mail==0.9.0
flask-socketio==3.0.2
setuptools==45
# Database
Flask-SQLAlchemy==2.3.2
psycopg2==2.7.5
SQLAlchemy==1.2.14
mysqlclient==1.3.13
marshmallow==2.15.1
# Migrations
Flask-Migrate==2.3.1
# Forms
Flask-WTF==0.14.2
WTForms==2.1
# Deployment
gunicorn>=19.1.1
# Auth
Flask-Login==0.4.0
Flask-Bcrypt==0.7.1
anyjson==0.3.3
celery==3.1.18
pycrypto==2.6.1
pytz==2015.7
requests==2.20.0
GitPython==2.1.15
pymysql ==0.9.3
virtualenv --system-site-packages venv
pip3 install setuptools==45
pip2 install setuptools==45
[root@admin walle-web]# cat walle/config/settings_prod.py
# -*- coding: utf-8 -*-
"""
walle-web
Application configuration.
注意: 带了 @TODO 的地方可能需要你的调整
:copyright: © 2015-2019 walle-web.io
:created time: 2018-11-24 07:05:35
:author: wushuiyong@walle-web.io
"""
import os
from walle.config.settings import Config
SETTINGS = {
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "Ad1234",
"MYSQL_DATABASE": "walle",
"MYSQL_ROOT_PASSWORD": "walle",
"MYSQL_HOST": "192.168.20.9",
"MYSQL_PORT": 3306,
}
class ProdConfig(Config):
"""Production configuration."""
ENV = 'prod'
DEBUG = False
SQLALCHEMY_ECHO = False
# 服务启动 @TODO
# HOST 修改为与 nginx server_name 一致.
# 后续在web hooks与通知中用到此域名.
HOST = 'admin.walle-web.io'
PORT = 5000
# https True, http False
SSL = False
# 数据库设置 @TODO
# SQLALCHEMY_DATABASE_URI = 'mysql://user:password@localhost:3306/walle?charset=utf8'
SQLALCHEMY_DATABASE_URI = 'mysql://{}:{}@{}:{}/{}?charset=utf8mb4'.format(
SETTINGS["MYSQL_USER"], SETTINGS["MYSQL_PASSWORD"], SETTINGS["MYSQL_HOST"], SETTINGS["MYSQL_PORT"],
SETTINGS["MYSQL_DATABASE"])
# 阿里云RDS强制释放空闲连接导致经常报错 mysql server has gone way
# 适当修改该参数即可 单位为秒
# N秒不用的连接自动释放
# SQLALCHEMY_POOL_RECYCLE = 30
# 本地代码检出路径(用户查询分支, 编译, 打包) #TODO
CODE_BASE = '/tmp/walle/codebase/'
# 日志存储路径 @TODO
# 默认为walle-web项目下logs, 可自定义路径, 需以 / 结尾
# LOG_PATH = '/var/logs/walle/'
LOG_PATH = os.path.join(Config.PROJECT_ROOT, 'logs')
LOG_PATH_ERROR = os.path.join(LOG_PATH, 'error.log')
LOG_PATH_INFO = os.path.join(LOG_PATH, 'info.log')
LOG_FILE_MAX_BYTES = 100 * 1024 * 1024
# 邮箱配置 @TODO
MAIL_SERVER = 'smtp.exmail.qq.com'
MAIL_PORT = 465
MAIL_USE_SSL = True
MAIL_USE_TLS = False
MAIL_DEFAULT_SENDER = 'service@walle-web.io'
MAIL_USERNAME = 'service@walle-web.io'
MAIL_PASSWORD = 'Ki9y&3U82'
# 登录cookie 防止退出浏览器重新登录
COOKIE_ENABLE = False
10.修改admin.sh
[root@admin walle-web]# cat admin.sh
#########################################################################
# File APP: admin.sh
# Author: wushuiyong
# mail: wushuiyong@walle-web.io
# Created Time: 2018年11月03日 星期六 06时09分46秒
#########################################################################
# Update Time : 2019-03-05
# Author: alenx <alenx.hai@gmail.com>
# -->> 新增ubuntu初始化,全面支持Ubuntu环境(16.x/18.x)
#########################################################################
#!/usr/bin/env bash
# ubuntu 高版本 sh 指向的是 dash 而非 bash。 dash 无法使用 function 关键字以及 source 等命令。
# 如果检测到 sh 指向的是 dash, 那么将使用 bash 重新执行脚本,然后在参数末尾加上一个 flag, 表示此次运行是修正过的, 避免陷入死循环。
fix_ubuntu_bash="fix-sh-in-ubuntu"
if [[ ! -n "$(echo $@ | grep ${fix_ubuntu_bash})" ]]; then
if [[ -n "$(ls -l /bin/sh | grep "dash")" ]]; then
bash $0 $@ ${fix_ubuntu_bash}
virtualenv --no-site-packages -p /usr/bin/python3 venv
exit
fi
fi
APP="waller.py"
function init() {
echo "Initing walle"
echo "----------------"
SystemName
pip3 install virtualenv
if [ ! -d "venv" ]; then
virtualenv --no-site-packages venv # 注意:安装失败请指定python路径. mac 可能会有用anaconda的python. 请不要mac试用, 麻烦多多
fi
requirement
echo "************************************************"
echo -e "\033[32m init walle success \033[0m"
echo -e "\033[32m welcome to walle 2.0 \033[0m"
}
function requirement() {
source ./venv/bin/activate
pip3 install -r ./requirements/prod.txt -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
}
function SystemName() {
source /etc/os-release
case $ID in
centos|fedora|rhel)
which pip3
if [ $? != "0" ]; then
wget https://bootstrap.pypa.io/3.3/get-pip.py
python get-pip.py
fi
echo "安装/更新可能缺少的依赖: mysql-community-devel gcc gcc-c++ python-devel"
# 安装python-devel报错 yum install yum-utils ,yum clean all yum -y install python-devel
sudo yum install -y yum-utils mariadb-devel mysql-devel --skip-broken gcc gcc-c++ python3-devel MySQL-python3
;;
debian|ubuntu|devuan)
echo "安装/更新可能缺少的依赖: libmysqld-dev libmysqlclient-dev python-dev python-virtualenv python-pip"
sudo apt update -y
sudo apt install -y libmysqld-dev libmysqlclient-dev python-dev python-virtualenv python-pip
;;
raspbian)
echo "安装/更新可能缺少的依赖"
sudo apt update -y
sudo apt install -y gcc g++ python-dev virtualenv python-pip libpq-dev libffi-dev libssl-dev libmariadbd18 libmariadbd-dev
;;
*)
exit 1
;;
esac
}
11.手动安装组件
pip install -r requirements/prod.txt
pip3 install -r requirements/prod.txt
sh admin.sh init
sh admin.sh migration
sh admin.sh start
登录瓦力
初始登录账号如下,开启你的walle 2.0之旅吧:)
超管:super@walle-web.io \ Walle123 所有者:owner@walle-web.io \ Walle123 负责人:master@walle-web.io \ Walle123 开发者:developer@walle-web.io \ Walle123 访客:reporter@walle-web.io \ Walle123 |