[运维] 在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
pip3 install pyflakes

运行依赖安装

dnf install python36-devel openldap-devel nginx
pip3 install cherrypy python-ldap python-pam Cheetah3 lxml psutil jsonschema
pip3 install websockify==0.7.0

wok安装

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

配置wok

  1. 关闭SELinux
# 永久关闭/启动:修改/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 '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. 报错信息如下
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”

猜你喜欢

转载自blog.csdn.net/macaiyun0629/article/details/109211522