如何在Heroku平台部署MoinMoin Wiki服务器?部署遇应用错误求助
Hey there, let's break down why your MoinMoin 1.9.9 app (running Python 2.7) is throwing that Application Error on Heroku. The logs you shared only show the initial startup info—we need more details to pinpoint the issue, but let's walk through the most common fixes first:
1. First, Grab the Full Real-Time Logs
The truncated logs you provided don't show the actual failure reason. Heroku keeps detailed logs, so run this command in your terminal to stream real-time output as your app tries to start:
heroku logs --tail
Look for lines marked ERROR or CRITICAL—these will tell you exactly what's breaking (like port binding failures, missing dependencies, or permission issues).
2. Fix Your Procfile (Critical for Heroku Deployment)
Heroku uses the Procfile to know how to launch your app. MoinMoin 1.9.9 needs a WSGI server that binds to Heroku's dynamic port never hardcode a port number—Heroku assigns one via the $PORT environment variable.
Make sure your Procfile (in your project root) looks like one of these:
Option 1: Use MoinMoin's built-in WSGI server
web: python -m MoinMoin.server.wsgiserver --port $PORT
Option 2: Use Gunicorn (more stable for production)
First, add a Python 2.7-compatible version of Gunicorn to your requirements.txt:
gunicorn==19.9.0
Then update your Procfile:
web: gunicorn --pythonpath /app MoinMoin.web.wsgi:application --bind 0.0.0.0:$PORT
3. Verify Dependencies in requirements.txt
Double-check that your requirements.txt includes all necessary packages for MoinMoin 1.9.9. At minimum, it should have:
MoinMoin==1.9.9 # Add any other dependencies your wiki uses (e.g., for plugins or image processing)
If you're missing a package, Heroku will throw an ImportError during startup—this will show up clearly in the full logs.
4. Install Required System Libraries
MoinMoin 1.9.9 relies on some system-level libraries (like libxml2 for XML processing or libjpeg for image uploads) that Heroku doesn't include by default. To fix this:
- Create an
Aptfilein your project root with the needed libraries:
libxml2-dev libjpeg-dev
- Add the Heroku Apt buildpack to your app:
heroku buildpacks:add --index 1 heroku-community/apt
This will install the system packages before your Python dependencies.
5. Ensure Write Permissions for MoinMoin Directories
MoinMoin needs to write to its data and underlay directories. Heroku's filesystem is temporary but writable—update your wikiconfig.py to point to valid paths:
data_dir = '/app/data' underlay_dir = '/app/underlay'
To avoid "directory not found" errors, add directory creation to your Procfile:
web: mkdir -p /app/data /app/underlay && python -m MoinMoin.server.wsgiserver --port $PORT
After checking these steps, redeploy your app with git push heroku main and watch the logs with heroku logs --tail to confirm if the issue is fixed. If you still hit errors, share the full error lines and we can dig deeper!
内容的提问来源于stack exchange,提问作者Yashwanth Kumar

