Skip to content

安装手册

lykops edited this page Jan 1, 2018 · 9 revisions

仅适用于v2.1之前的版本,新版本wiki请看https://github.com/lykops/lykchat/

配置运行环境

关闭selinux
防火墙允许外网访问80端口或者直接关闭防火墙

安装依赖包

yum install -y epel-release 
yum install telnet ntpdate lrzsz bash glibc openssl openssl-devel openssl-static openssl098e openssl-libs vim automake autoconf gcc xz ncurses-devel patch python-devel git python-pip gcc-c++ redhat-rpm-config -y
yum upgrade -y

配置nginx

先安装nginx
配置nginx服务器,conf/nginx.conf,添加
    location / {
        proxy_redirect off;
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://localhost:8000;
    }
    location /static/ {
        alias /opt/lykchat/static/;
    }

配置mysql

在本地安装mysql
rpm -ivh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
yum install mysql-community-client mysql-community-common mysql-community-devel mysql-community-libs  mysql-community-libs-compat mysql-community-server --skip-broke

新增一个数据库lykchat
设置用户lykchat,密码为!QAZ2wsx,把数据库lykchat的权限分配给用户lykchat

编译安装python

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz -c
tar zxvf Python-3.6.0.tgz
cd Python-3.6.0
./configure --prefix=/usr/local/python36/ --enable-optimizations && make && make install

安装python模块

下载程序,解压到/opt/
/usr/local/python36/bin/pip3 install -r /opt/lykchat/install/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

配置应用程序

修改配置文件

配置文件library/config/wechat.py
如果未按默认方式运行的话,需要修改以下参数:
	数据库配置:DATABASES
	session过期时间:SESSION_COOKIE_AGE,默认1小时
	nginx修改端口或者使用域名访问,修改url_frond
		该项目部署URL基础地址:url_frond,默认为http://127.0.0.1/
		如果修改了nginx端口或者基础地址的话,需要修改此处,否则微信登陆检测失败
		强烈建议使用根目录部署,不要部署在二级目录下(例如http://127.0.0.1/lykchat),导致内部页面跳转异常
	web登陆和接口账号和密码:user_mess_dict 

初始化数据库和配置计划任务

/usr/local/python36/bin/python3 /opt/lykchat/manage.py makemigrations
/usr/local/python36/bin/python3 /opt/lykchat/manage.py migrate

/usr/local/python36/bin/python3 /opt/lykchat/manage.py crontab add
crontab -l
如果有类似这条
    * * * * * /usr/bin/python3 /opt/lykchat/manage.py crontab run 6d8f0feaeaa440358a85dfc8d5efa2af >>/dev/shm/lykchat.txt 2>&1 # django-cronjobs for lykchat
说明OK

运行该计划任务,没有报错即可

启动服务

service mysqld restart
nginx
/usr/local/python36/bin/python3 /opt/lykchat/manage.py runserver 

以上命令记得做开机启动哦

访问ip地址即可