[运维] 在CentOS8系统上安装部署wok

it2025-05-04  10

系统环境说明

系统:CentOS-8.2.2004 平台:x86-64

使用到的工具安装

git安装 dnf install git

软件下载

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

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

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

依赖安装

编译依赖安装

wok编译需要automake、gcc 、make 等依赖

dnf install automake gcc make libtool libxslt gettext-devel pip3 install pyflakes pyyaml

运行依赖安装

dnf install python36-devel openldap-devel nginx 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

关闭SELinux setenforce 0 # 临时关闭 # 永久关闭/启动:修改/etc/sysconfig/selinux后重启系统 vim /etc/sysconfig/selinux # 将“SELINUX=enforcing“改成“SELINUX=desabled” 防火墙放通访问端口,wok默认使用8001端口,防火墙常用操作见centos8 防火墙常用操作 firewall-cmd --add-port=8001/tcp --permanent firewall-cmd --reload 设置开机启动 systemctl enable wokd

启用开发模式调试

python3 /bin/wokd --environment=dev

wok插件安装

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

常见问题

编译问题

执行./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工具

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

解决办法:缺少gcc

dnf install gcc 报错信息如下 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 报错信息如下 checking whether make sets $(MAKE)... no

解决办法:缺少make

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

解决办法:

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

解决办法:

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

解决办法:

dnf install libxslt

运行问题

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

解决办法:

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

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

pip3 install python-ldap 报错信息如下 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 报错信息如下 ModuleNotFoundError: No module named 'Cheetah'

解决办法:

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

解决办法:

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

解决办法:

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

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

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

解决办法:

pip3 install jsonschema 报错信息如下 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.

解决办法:

dnf install nginx 报错信息如下 ModuleNotFoundError: No module named 'OpenSSL'

解决办法:

pip3 install pyOpenSSL

配置问题

报错信息如下 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”

环境配置问题

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

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

# wok include /etc/nginx/conf.d/*.conf; 当使用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
最新回复(0)