系统环境说明

系统:Debian 10 buster
平台:x86-64

使用到的工具安装

  1. git安装
sudo apt install git

软件下载

采用编译安装,源代码获取

git clone https://github.com/kimchi-project/wok.git

源代码从github签出速度比较慢,可以使用国内镜像加速,使用国内镜像加速方法见Github国内mirror加速,加速镜像见GitHub 加速镜像

依赖安装

编译依赖安装

wok编译需要automakegccmake 等依赖

sudo apt install automake gcc make libtool python3-pip gettext pkg-config
sudo apt install libxslt1.1 
pip3 install pyflakes pyyaml

运行依赖安装

sudo apt install libldap2-dev nginx libsasl2-dev python3-openssl
pip3 install cherrypy python-ldap python-pam Cheetah3 lxml psutil jsonschema pyOpenSSL 
pip3 install websockify==0.7.0

wok安装

cd wok
git checkout 3.0.0
./autogen.sh --system
make 
make install

配置wok

  1. 防火墙放通访问端口,wok默认使用8001端口
sudo ufw allow 8001
sudo ufw reload
  1. 设置开机启动
systemctl enable wokd
  1. 允许普通用户使用root
su root
apt install sudo
sudo usermod -aG sudo YourUsername

启用开发模式调试

python3 /bin/wokd --environment=dev

wok插件安装

  1. kimchi安装,见在CentOS8安装部署kimchi

常见问题

编译问题

  1. 执行./autogen.sh --system报如下错误
./autogen.sh: line 23: aclocal: command not found
./autogen.sh: line 24: automake: command not found
./autogen.sh: line 25: autoreconf: command not found

解决方法:缺少automake工具

sudo apt install automake
  1. 报错信息如下
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: no acceptable C compiler found in $PATH

解决办法:缺少gcc

sudo apt install gcc
  1. 报错信息如下
configure.ac:59: error: required file 'build-aux/compile' not found
configure.ac:59:   'automake --add-missing' can install 'compile'
configure.ac:59: error: required file 'build-aux/config.guess' not found
configure.ac:59:   'automake --add-missing' can install 'config.guess'
configure.ac:59: error: required file 'build-aux/config.sub' not found
configure.ac:59:   'automake --add-missing' can install 'config.sub'

解决办法:

## 可能需要多执行几次此命令
automake --add-missing
  1. 报错信息如下
checking whether make sets $(MAKE)... no

解决办法:缺少make

sudo apt install make
  1. 报错信息如下
checking for pyflakes... no
configure: WARNING: pyflakes not found

解决办法:

pip3 install pyflakes
  1. 报错信息如下
ModuleNotFoundError: No module named 'yaml'

解决办法:

pip3 install pyyaml
  1. 报错信息如下
xsltproc: Command not found

解决办法:

sudo apt install libxslt1.1

运行问题

  1. 报错信息如下
ModuleNotFoundError: No module named 'cherrypy'

解决办法:

pip3 install cherrypy
  1. 报错信息如下
ModuleNotFoundError: No module named 'ldap'

解决办法:安装过程中出现报错,处理办法见 python常见错误处理[CentOS8系统](pip安装应用)

pip3 install python-ldap
  1. 报错信息如下
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/wok/auth.py", line 34, in <module>
    import PAM
ModuleNotFoundError: No module named 'PAM'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/bin/wokd", line 30, in <module>
    import wok.server
  File "/usr/lib/python3.6/site-packages/wok/server.py", line 28, in <module>
    from wok import auth
  File "/usr/lib/python3.6/site-packages/wok/auth.py", line 36, in <module>
    import pam as PAM
ModuleNotFoundError: No module named 'pam'

解决办法:

pip3 install python-pam
  1. 报错信息如下
ModuleNotFoundError: No module named 'Cheetah'

解决办法:

pip3 install Cheetah3
  1. 报错信息如下
ModuleNotFoundError: No module named 'lxml'

解决办法:

pip3 install lxml
  1. 报错信息如下
ModuleNotFoundError: No module named 'psutil'

解决办法:

pip3 install psutil
  1. 报错信息如下
ModuleNotFoundError: No module named 'websockify'

解决办法:注意:kimchi使用最新版websockify时存在问题

pip3 install websockify==0.7.0
  1. 报错信息如下
ModuleNotFoundError: No module named 'jsonschema'

解决办法:

pip3 install jsonschema
  1. 报错信息如下
rc: 4 error: Redirecting to /bin/systemctl status nginx.service
Unit nginx.service could not be found.
 returned from cmd: service nginx status
Redirecting to /bin/systemctl start nginx.service
Failed to start nginx.service: Unit nginx.service not found.

解决办法:

sudo apt install nginx
  1. 报错信息如下
ModuleNotFoundError: No module named 'OpenSSL'

解决办法:

pip3 install pyOpenSSL

配置问题

  1. 报错信息如下
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

执行systemctl status nginx.service后,显示报错信息如下

Oct 23 21:57:03 kimchi nginx[63332]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Oct 23 21:57:03 kimchi nginx[63332]: nginx: [emerg] bind() to 0.0.0.0:8001 failed (13: Permission denied)
Oct 23 21:57:03 kimchi nginx[63332]: nginx: configuration file /etc/nginx/nginx.conf test failed

执行tail -100f /var/log/nginx/error.log命令查看日志错误信息,显示错误信息如下

63706#0: bind() to 0.0.0.0:8001 failed (13: Permission denied)

解决办法:问题的产生原因是 SELinux 基于最小权限原则默认拦截了 Nginx 的请求,可以通过关闭SELinux解决

# 临时关闭 SELinux
setenforce 0
# 临时启动 
SELinux:setenforce 1
# 永久关闭/启动:修改/etc/sysconfig/selinux后重启系统
vim /etc/sysconfig/selinux # 将“SELINUX=enforcing“改成“SELINUX=desabled”

环境配置问题

  1. 如果是编译安装nginx,并且使用默认路径安装,则需创建nginx服务启动文件
    编辑/usr/lib/systemd/system/nginx.service
vim /usr/local/nginx/conf/nginx.conf

http {}属性中添加以下内容

    # wok
    include /etc/nginx/conf.d/*.conf;
  1. 当使用asdf安装python时,则需要重写启动脚本
    编辑/usr/bin/wokd-wrapper文件
vim /usr/bin/wokd-wrapper

添加以下内容

#!/bin/bash

. /root/.asdf/asdf.sh
asdf local python 3.6.12

/root/.asdf/shims/python /bin/wokd

编辑/usr/lib/systemd/system/wokd.service文件

vim /usr/lib/systemd/system/wokd.service

将以下内容覆盖原文件

[Unit]
Description=Wok - Webserver Originated from Kimchi
Documentation=https://github.com/kimchi-project/wok/wiki
Wants=nginx.service
After=nginx.service
Wants=apache2.service
After=apache2.service

[Service]
Type=simple
User=root
ExecStart=/usr/bin/wokd-wrapper
ExecStop=/usr/bin/pkill -s $MAINPID
EnvironmentFile=/etc/wok/wok.conf
KillMode=process

[Install]
WantedBy=multi-user.target
Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐