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

Cpanel部署Django网站执行collectstatic触发ImproperlyConfigured错误求助

Fixing Django collectstatic ImproperlyConfigured Error on cPanel

Hey there, let's work through this collectstatic issue you're hitting. The error says you haven't set STATIC_ROOT, but you clearly have it in your settings—so the problem is likely that Django isn't picking up your configured value for some reason. Here are the most common fixes to try:

1. Verify Django is loading the correct settings file

It's possible you modified one settings.py file, but Django is actually using a different one (like a production-specific settings_prod.py or a file specified by cPanel's Django manager). To check:

  • Activate your virtual environment (if you haven't already)
  • Run this command to launch a Django shell:
    python manage.py shell
    
  • Inside the shell, run these lines to check what STATIC_ROOT Django is seeing:
    from django.conf import settings
    print(settings.STATIC_ROOT)
    

If the output doesn't match the path you set (/home/****/public_html/static), you need to find and modify the actual settings file that Django is using.

2. Fix the STATIC_ROOT path placeholder

Looking at your virtual environment path (/home/massvnrc/virtualenv/mysite/3.7/...), your cPanel username is massvnrc—but your STATIC_ROOT uses **** as a placeholder. Replace that with your actual username to make the path valid:

STATIC_ROOT='/home/massvnrc/public_html/static'

Also, make sure this directory exists on your server (you can create it via cPanel's File Manager if it doesn't).

3. Confirm cPanel's Django app settings are pointing to the right module

Many cPanel installations let you specify which settings module your Django app uses. Double-check this in your cPanel Django application configuration:

  • Go to your cPanel's "Django App Manager" (or similar tool)
  • Find your site's configuration
  • Ensure the "Settings Module" field matches your project's settings path (e.g., mysite.settings if your settings are in mysite/mysite/settings.py)

4. Explicitly specify the settings file when running collectstatic

If Django is still not picking up your settings, try forcing it to use your modified file with this command:

python manage.py collectstatic --settings=mysite.settings

(Replace mysite with your actual Django project folder name if it differs.)

Once you've tried these steps, run collectstatic again—it should recognize your STATIC_ROOT setting and proceed with collecting your static files.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 11:57:38