maple-bbs 笔记

前端之家收集整理的这篇文章主要介绍了maple-bbs 笔记前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1:prerequirement

apt install python3-virtualenv libjpeg-dev
apt-get install libMysqLclient-dev python3-dev redis-server MysqL-server
mkdir logs
MysqL  -u root -p
create database bbsdb
vim /etc/redis/redis.conf
requirepass bbsredis 
systemctl restart redis
#config.py
which python3
virtualenv -p  /usr/bin/python3 bbsenv

2:验证码无法加载的问题及解决方法

raise ImportError("The _imagingft C module is not installed")

ImportError: The _imagingft C module

#在虚拟环境下
pip uninstall pillow
#给系统安装相应库
sudo apt-get install libjpeg-dev
sudo apt-get install libpng-dev

重新安装pillow

pip install pillow

3:centos安装MysqL

$ wget http://repo.MysqL.com/MysqL-community-release-el7-5.noarch.rpm
$ sudo rpm -ivh MysqL-community-release-el7-5.noarch.rpm
$ sudo yum install MysqL-server

4:重设MysqL的密码

MysqL -u root
use MysqL
update user set password=password("new_pass") where user="root";
flush privileges;  

创建数据库

create database bbsdb

5: 进入虚拟环境,并使用gunicorn测试运行

(bbsenv) [root@iZ8vbdzx7y7owlnigdrmixZ bbsforums-master]# python runserver.py initdb
(bbsenv) [root@iZ8vbdzx7y7owlnigdrmixZ bbsforums-master]# python runserver.py create_index
(bbsenv) [root@iZ8vbdzx7y7owlnigdrmixZ bbsforums-master]# python runserver.py create_user
(bbsenv) [root@iZ8vbdzx7y7owlnigdrmixZ bbsforums-master]# gunicorn -c gunicorn.conf uwsgi:app 
#使用httpie对首页发出head请求进行测试(stauts code为200,正常)
[root@iZ8vbdzx7y7owlnigdrmixZ ~]# http head http://127.0.0.1:8080 
HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 10815
Content-Type: text/html; charset=utf-8
Date: Tue,13 Mar 2018 05:16:01 GMT
Server: gunicorn/19.4.5
Set-Cookie: remember_token=; Expires=Thu,01-Jan-1970 00:00:00 GMT; Max-Age=0; Path=/
Set-Cookie: session=eyJjc3JmX3Rva2VuIjoiOGU3ODBmMGQyYjYyNTJkZmZhYTk1MGFjN2VkYTc0MDAxYWRkOTNlNCJ9.DYjwEQ.X3l-fs6cRWmzmnrPZl5yFl5oN9U; HttpOnly; Path=/

6:配置Nginx

vim /etc/Nginx/Nginx.conf

server {
listen 80;
servername ; #这是HOST机器的外部域名,用ip地址也行

location / {
    proxy_pass http://127.0.0.1:8080;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

}</code></pre>

7:centos下验证码字体缺失问题及解决方法

self.font = core.getfont(font,size,index,encoding)

IOError: cannot open resource

yum install dejavu-sans*
mkdir /usr/share/fonts/TTF/
cp  /usr/share/fonts/dejavu/DejaVuSans.ttf  /usr/share/fonts/TTF/

8:启动forums

source bbsenv/bin/activate
cd bbsforums-master/
(bbsenv) [root@bss]# pwd
/root/bbsforums-master
(bbsenv) [root@bbs]# bash rungunicorn.sh &
systemctl start/restart Nginx

跑通forums的整个过程(只支持python3,不兼容python2中package命名的问题)

1:下载原码,查看官网的简单教程

2:修改config.py (cp config.example config.py),需要修改内容如下:

CACHE_TYPE = 'null'  #可改为'simple'
CACHE_REDIS_PASSWORD = 'your password' #设置自己的redis密码
REDIS = {'db': 1,'password': 'your password','decode_responses': True}  #设置自己的redis密码
SERVER_NAME = 'localhost:8000' #这一行注释掉,否则你会有意外的惊喜 
SUBDOMAIN = {'forums': True,'docs': True}  #'forums':False
sqlALCHEMY_DATABASE_URI = 'MysqL://username:password@server/db' #设置自己MysqL用户名,密码,数据库

3:安装依赖

主要包括MysqL,redis,python3-virtual等其它为库

4:安装python的虚拟运行环境并激活

virtualenv -p /usr/bin/python3 bbsenv
source bbsenv/bin/activate

5:安装项目的python依赖

cd 项目
pip install -r requirements.txt

6:测试运行

进入MysqL命令行,创建与config.py中对应的数据库
修改redis的密码
重启redis 和 MysqL
python runserver.py initdb  #创建forums所有数据库
python runserver.py create_index #创建index,给缓存用
python runserver.py create_user #创建管理员
python runserver.py  #运行论坛,使用httpie或浏览器进行访问测试
原文链接:https://www.f2er.com/note/411527.html

猜你在找的程序笔记相关文章