我已经运行了 Modoboa 的手动安装(https://modoboa.readthedocs.io/en/latest/installation.html#manual-installation),它在 uWSGI 中运行一个 webapp。我将静态内容移至 /var/www/html,其余内容则放在 /opt/modoboa 中,该目录由 modoboa 用户拥有。还有一些 cron 作业也应以 modoboa 用户身份运行。
uid
如果我通过在 uWSGI ini 文件中设置和以用户 modoboa 身份启动 uWSGI 服务器guid = modoboa
,我可以访问 Web 应用并使用所有功能。但是应该由 modoboa 用户执行的脚本会提示我输入密码 - 我无法确定系统的哪个部分需要 root 访问权限。
以 root 身份运行以下命令来执行安装:
mkdir -p /opt/modoboa
cd /opt/modoboa
virtualenv --python python3 ./env
source ./env/bin/activate
pip install mysqlclient
pip install modoboa
modoboa-admin.py deploy instance --collectstatic --domain mail.mydomain.com --dburl default:mysql://modoboa:$db_user_password-modoboa@[localhost]/modoboa
chown -R modoboa:modoboa env/
chown -R modoboa:modoboa instance/
mkdir -p /var/www/html/mail
mv instance/frontend/ instance/media/ instance/sitestatic/ /var/www/html/mail/
pip install uwsgi
echo "[uwsgi]
socket = 127.0.0.1:3031
chdir = /opt/modoboa/instance
module = instance.wsgi:application
uid = modoboa
gid = modoboa
master = true
harakiri = 60
processes = 4
vhost = true
no-default-app = true
log-master = true
single-interpreter = true
logto = /opt/modoboa/modoboa.log
die-on-term = true" > /opt/modoboa/modoboa.ini
touch /opt/modoboa/modoboa.log
chown -R modoboa:modoboa /opt/modoboa/modoboa.log /opt/modoboa/modoboa.ini
echo '[Unit]
Description=uWSGI instance to serve modoboa
After=network.target
[Service]
ExecStart=/opt/modoboa/env/bin/uwsgi --ini /opt/modoboa/modoboa.ini
Restart=always
KillSignal=SIGQUIT
Type=notify
StandardError=syslog
NotifyAccess=all
[Install]
WantedBy=multi-user.target' > /etc/systemd/system/modoboa.service
systemctl enable modoboa.service
systemctl start modoboa.service
编辑:
经过进一步调查,我找到了问题的根源。我将 modoboa 用户添加到 dovecot 组,但这没有帮助
available_schemes = get_dovecot_schemes()
File "/opt/modoboa/env/lib/python3.9/site-packages/modoboa/core/password_hashers/__init__.py", line 49, in get_dovecot_schemes
retcode, schemes = doveadm_cmd("pw -l")
File "/opt/modoboa/env/lib/python3.9/site-packages/modoboa/lib/sysutils.py", line 76, in doveadm_cmd
return exec_cmd("{} {}".format(dpath, params),
File "/opt/modoboa/env/lib/python3.9/site-packages/modoboa/lib/sysutils.py", line 39, in exec_cmd
output = process.communicate(*c_args)[0]
File "/usr/lib64/python3.9/subprocess.py", line 1121, in communicate
stdout = self.stdout.read()
KeyboardInterrupt