在CyberPanel上托管Django应用时遭遇500 Internal Server Error问题求助
I totally get how frustrating this 500 error is, especially after you’ve gone through the steps of setting up your site, configuring the Django deployment, and tweaking the vHost. Let’s walk through some actionable troubleshooting steps to get this sorted:
1. Start with CyberPanel’s Own Logs
First, let’s get to the root of the error by checking CyberPanel’s logs. The main logs are usually stored in /var/log/cyberpanel/. Run this command to watch the error log in real-time:
tail -f /var/log/cyberpanel/error.log
Now refresh the "LIST WEBSITES" page in CyberPanel—any new error entries here will point you directly to what’s breaking the screenshot service or underlying site.
2. Verify Your Django App Is Actually Running
The screenshot error might be a side effect of your Django app throwing its own 500 error. Let’s confirm the app itself is accessible:
- Try accessing your domain directly in a browser, or use
curlfrom the server:curl http://your-domain.com - If the app is returning a 500, fix that first:
- Check Django’s internal logs (look for a
logsdirectory in your project root, or check theLOGGINGconfig insettings.pyfor the exact path). - Double-check that your domain is added to
ALLOWED_HOSTSinsettings.py—Django blocks requests from unlisted hosts by default:ALLOWED_HOSTS = ['your-domain.com', 'www.your-domain.com'] - Ensure all Python dependencies are installed correctly. Activate your virtual environment and run
pip listto confirm nothing is missing.
- Check Django’s internal logs (look for a
3. Validate Your vHost Configuration
Since you modified the vHost, a syntax error or incorrect path could be causing issues. CyberPanel stores vHost configs in /usr/local/lsws/conf/vhosts/your-domain.com/vhconf.conf:
- Open the file and verify the
wsgiScriptPathpoints to your Django project’swsgi.pyfile with the correct absolute path. It should look something like:wsgiScriptPath /home/your-domain.com/public_html/your-django-project/wsgi.py - Check for typos, missing brackets, or invalid directives. You can test if the config is valid by restarting OpenLiteSpeed:
lswsctrl restart
If the restart fails, the error message will tell you exactly where the config is broken.
4. Fix File Permissions
Incorrect file permissions are a common culprit for 500 errors in CyberPanel/Django setups:
- Make sure your Django project files and directories are owned by your site’s user (usually the same as your domain name). You can set this with:
chown -R your-domain-user:your-domain-user /home/your-domain.com/public_html/your-django-project/ - Set directory permissions to
755and file permissions to644:find /home/your-domain.com/public_html/your-django-project/ -type d -exec chmod 755 {} \; find /home/your-domain.com/public_html/your-django-project/ -type f -exec chmod 644 {} \; - Ensure the
staticandmediafolders have proper read/write permissions so Django can serve static assets.
5. Restart CyberPanel Services
If all else checks out, the screenshot service itself might be glitching. Try restarting CyberPanel and its related services:
systemctl restart cyberpanel systemctl restart lscpd
After restarting, refresh the "LIST WEBSITES" page to see if the screenshot error is gone.
Start with checking the logs—they’ll give you the most specific info about what’s wrong. Once you fix the underlying issue (whether it’s Django, vHost config, or permissions), the screenshot error should resolve itself.
内容的提问来源于stack exchange,提问作者Namita Tare




