You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在Manjaro(Arch)上通过Apache2虚拟主机+mod_wsgi部署Flask应用求助

Hey there, let's get your Flask app up and running with mod_wsgi on Apache 2.4 in Manjaro. I’ll walk through the most common pitfalls and fixes based on your setup:

1. Make sure mod_wsgi is tied to Python 3.6

Arch-based distros like Manjaro sometimes have mod_wsgi linked to a different Python version by default. Let’s verify and fix this:

  • First, check which Python version mod_wsgi is using:
    mod_wsgi-express module-config
    
    Look for the PythonPath line—if it doesn’t point to Python 3.6’s directory, you’ll need to install a version of mod_wsgi compiled for 3.6.
  • Install mod_wsgi via pip for Python 3.6:
    pip3.6 install mod_wsgi
    
  • Run mod_wsgi-express module-config again, then copy the three output lines (starting with LoadModule, WSGIPythonHome, WSGIPythonPath) and add them to your Apache config file (usually /etc/httpd/conf/httpd.conf or a new file in /etc/httpd/conf.d/).
2. Fix your VirtualHost configuration

Let’s adjust your Apache virtual host to ensure it points correctly to your app and grants proper permissions:

  • Here’s a corrected example configuration tailored to your setup:
    <VirtualHost *:80>
        # Replace with your actual domain or server IP
        ServerName dashboard.yourdomain.com
    
        # Define a daemon process for your app, pointing to the app directory
        WSGIDaemonProcess sonntag-dashboard python-path=/srv/http/dashboard
        WSGIProcessGroup sonntag-dashboard
        # Map the root URL to your WSGI script
        WSGIScriptAlias / /srv/http/dashboard/wsgi.py
    
        # Grant Apache access to the app directory
        <Directory /srv/http/dashboard>
            Require all granted
        </Directory>
    
        # Logging for debugging
        ErrorLog /var/log/httpd/dashboard-error.log
        CustomLog /var/log/httpd/dashboard-access.log combined
    </VirtualHost>
    
  • If you’re using a Python virtual environment for your Flask app, add python-home=/srv/http/dashboard/your-venv to the WSGIDaemonProcess line (replace your-venv with your actual venv directory).
3. Validate your WSGI entry file

Ensure your wsgi.py (in /srv/http/dashboard) is set up correctly to expose your Flask app:

import sys
# Add the app directory to Python's path to ensure it finds SonntagDashboard
sys.path.insert(0, '/srv/http/dashboard')

# Import your Flask app instance and rename it to 'application' (required by mod_wsgi)
from SonntagDashboard import app as application

# Important: Disable debug mode in production!
# application.debug = True
4. Set proper file permissions

Apache runs as the http user in Manjaro, so it needs access to your app files:

# Give ownership to the Apache user/group
chown -R http:http /srv/http/dashboard
# Set readable/execute permissions for the directory
chmod -R 755 /srv/http/dashboard
5. Test and restart Apache
  • First, check for config syntax errors:
    apachectl configtest
    
  • If everything looks good, restart Apache to apply changes:
    systemctl restart httpd
    
  • If you still run into issues, check the error logs for details:
    cat /var/log/httpd/dashboard-error.log
    # Or view system logs for Apache
    journalctl -u httpd -f
    

These steps should resolve most common deployment issues with Flask + mod_wsgi on Manjaro. Let me know if you hit specific error messages we can troubleshoot further!

内容的提问来源于stack exchange,提问作者Basti

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 09:14:34