静看光阴荏苒
不管不顾不问不说也不念

CentOS7安装owllook在线小说搜索引擎

最近真的太J8冷了,冻的都想冬眠了。。。这个是某网友多次找我说让我写个安装教程,我随便写下吧。。。

首先把系统的编码改为UTF8,一般的机器都是正常的,是我这台比较特殊,所以记录下,如果编码不是这个待会程序无法正常运行:

export LANG=en_US.UTF-8

更新是个好习惯,先更新系统:

yum -y update

安装EPEL源:

yum -y install epel-release

安装Redis和一些基本组件:

yum -y install redis git curl screen

现在运行并把Redis设置开机自启动:

systemctl start redis
systemctl enable redis

新建一个repo源,用于安装mongodb:

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

写入:

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

然后直接yum安装:

yum -y install mongodb-org

启动mongodb并设置开机启动:

systemctl start mongod
systemctl enable mongod

安装编译安装Python3所需的依赖:

yum -y install gcc make zlib zlib-devel readline readline-devel readline-static openssl openssl-devel openssl-static sqlite-devel bzip2-devel bzip2-libs libffi-devel

跑下面这个脚本安装pyenv:

curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

编辑账户配置文件:

vi ~/.bash_profile

加入如下环境变量:

export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

使其生效:

source ~/.bash_profile

使用pyenv安装python3.6.7:

pyenv install 3.6.7

完成之后创建一个3.6.7的虚拟运行环境:

pyenv virtualenv 3.6.7 owllook

记住你的这个环境路径,如下:

/root/.pyenv/versions/3.6.7/envs/owllook/bin/python3

现在拉取项目并进入到项目目录:

git clone https://github.com/howie6879/owllook
cd owllook

把项目目录的python环境设置为我们刚才创建的:

pyenv local owllook

使用pip安装pipenv:

pip install pipenv

然后使用pipenv安装项目所需依赖:

pipenv install --python /root/.pyenv/versions/3.6.7/envs/owllook/bin/python3

依赖安装完成如图所示,请确保这个过程没有任何错误:

完成之后进入到owllook目录内:

cd owllook

编辑配置文件:

vi config/config.py

找到如下这段代码:

VAL_HOST = os.getenv('VAL_HOST', 'true')

改为:

VAL_HOST = os.getenv('VAL_HOST', 'false')

现在使用screen创建一个新的shell:

screen -S owllook

在新shell内运行程序:

python server.py

不出意外,你可以看到类似下图的回显,就说明项目跑起来了:

现在我们安装Nginx用于反向代理:

yum -y install nginx

新建一个Nginx站点配置文件:

vi /etc/nginx/conf.d/book.conf

写入:

server {
    listen       80;
    server_name  example.com www.example.com;

location / {
    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 $scheme;
    proxy_set_header Host $http_host;
    proxy_set_header X-NginX-Proxy true;

    proxy_pass http://0.0.0.0:8001;
    proxy_redirect off;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    }
}

重启Nginx:

systemctl restart nginx

关闭防火墙和SElinux:

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

现在打开你的站点域名,应该可以正常访问这个程序了:

随便搜了个小说,可以正常工作:

至于排行榜不能显示的问题,我也不知道怎么解决,看作者说要运行spiders/spider_console.py,但是这个运行不鸟,报错。差不多就是这样子了。

更新:

是我2B了,spider_console.py是正常的可以运行:

cd owllook/owllook/spiders

然后用screen创建一个新的shell:

screen -S spider_console

在新shell里执行:

python spider_console.py
赞(2)
未经允许不得转载:荒岛 » CentOS7安装owllook在线小说搜索引擎
分享到: 更多 (0)

评论 15

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    感觉很一般啊~ :arrow:

    george5年前 (2018-12-09) Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 10 x64 Edition Windows 10 x64 Edition回复
  2. #2

    :roll: :roll: :roll:

    王富贵的富贵5年前 (2018-12-09) Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 10 x64 Edition Windows 10 x64 Edition回复
  3. #3

    会不会有啥版权问题 :grin:

    瞎折腾5年前 (2018-12-10) Google Chrome 68.0.3440.91 Google Chrome 68.0.3440.91 Android 6.0.1 Android 6.0.1回复
    • 不清楚。。。可能会有吧。。。

      LALA5年前 (2018-12-11) Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 10 x64 Edition Windows 10 x64 Edition回复
  4. #4

    大佬,spider_console.py运行报错,应该怎么解决?

    [2018-12-11 16:38:01,816] 8524-INFO __init__::load_config():l24: owllook 启动模式:PRO
    Traceback (most recent call last):
    File “spider_console.py”, line 10, in
    from owllook.spiders import QidianRankingSpider, ZHRankingSpider
    File “../../owllook/spiders/__init__.py”, line 1, in
    from .qidian_ranking import QidianRankingSpider
    File “../../owllook/spiders/qidian_ranking.py”, line 8, in
    from owllook.database.mongodb import MotorBaseOld
    File “../../owllook/database/mongodb/__init__.py”, line 1, in
    from .motorbase import MotorBase, MotorBaseOld, PyMongoDb
    File “../../owllook/database/mongodb/motorbase.py”, line 11, in
    @singleton
    File “../../owllook/database/mongodb/motorbase.py”, line 19, in MotorBase
    MONGODB = CONFIG.MONGODB
    AttributeError: type object ‘Config’ has no attribute ‘MONGODB’

    jiji5年前 (2018-12-11) Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 7 Windows 7回复
    • 没遇到过你这个错误。。。看样子像和Mongodb有关系。

      LALA5年前 (2018-12-11) Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 10 x64 Edition Windows 10 x64 Edition回复
  5. #5

    大佬,转载了,一直期望的教程!

    zhujiwiki5年前 (2018-12-16) Google Chrome 63.0.3239.132 Google Chrome 63.0.3239.132 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 好的。

      LALA5年前 (2018-12-17) Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 10 x64 Edition Windows 10 x64 Edition回复
  6. #6

    大佬,那么宝塔面板也可以装吗?

    ICE5年前 (2018-12-16) Google Chrome 71.0.3578.98 Google Chrome 71.0.3578.98 Windows 10 x64 Edition Windows 10 x64 Edition回复
    • 用宝塔的redis和nginx应该可以的。

      LALA5年前 (2018-12-17) Google Chrome 70.0.3538.110 Google Chrome 70.0.3538.110 Windows 10 x64 Edition Windows 10 x64 Edition回复

分享创造快乐

广告合作资源投稿