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

系统环境说明

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

使用到的工具安装

  1. git安装
dnf install git

软件下载

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

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

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

依赖安装

编译依赖安装

wok编译需要automakegccmake 等依赖

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

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

启用开发模式调试

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工具

dnf 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

dnf 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

dnf 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

解决办法:

dnf install libxslt

运行问题

  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.

解决办法:

dnf 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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值