Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django 生产中的静态文件404_Django - Fatal编程技术网

Django 生产中的静态文件404

Django 生产中的静态文件404,django,Django,部署我的应用程序后,没有加载任何静态文件。当我检查开发工具时,它们都是404 我运行了python3 manage.py collectstatic 设置.py STATIC_URL = '/static/' STATIC_ROOT = '/srv/example/static/' “我的静态文件夹”具有以下权限和所有权: drwxr-xr-x 8根根目录4096 11月17日23:28静态 My/etc/apache2/sites enabled/example.conf: <Vir

部署我的应用程序后,没有加载任何静态文件。当我检查开发工具时,它们都是404

我运行了
python3 manage.py collectstatic

设置.py

STATIC_URL = '/static/'
STATIC_ROOT = '/srv/example/static/'
“我的静态文件夹”具有以下权限和所有权:

drwxr-xr-x 8根根目录4096 11月17日23:28静态

My
/etc/apache2/sites enabled/example.conf

 <VirtualHost *:80>

       ErrorLog ${APACHE_LOG_DIR}/example-error.log
       CustomLog ${APACHE_LOG_DIR}/example-access.log combined

       WSGIDaemonProcess example processes=2 threads=25 python-ho>
       WSGIProcessGroup example
       WSGIScriptAlias / /srv/example/example/wsgi.py

      Alias /robots.txt /srv/example/static/robots.txt
      Alias /favicon.ico /srv/example/static/favicon.ico
      Alias /static /srv/example/static/
      Alias /media /srv/example/media/

      <Directory /srv/example/example>
          <Files wsgi.py>
              Require all granted
          </Files>
      </Directory>

      <Directory /srv/example/static>
          Require all granted
      </Directory>

      <Directory /srv/example/media>
          Require all granted
      </Directory>
</VirtualHost>

ErrorLog${APACHE_LOG_DIR}/example-error.LOG
CustomLog${APACHE_LOG_DIR}/example-access.LOG组合
WSGIDaemonProcess示例进程=2个线程=25个python ho>
WSGIProcessGroup示例
WSGIScriptAlias//srv/example/example/wsgi.py
别名/robots.txt/srv/example/static/robots.txt
别名/favicon.ico/srv/example/static/favicon.ico
别名/static/srv/example/static/
别名/media/srv/example/media/
要求所有授权
要求所有授权
要求所有授权
  • “collectstatic”之后是否检查文件是否在/static/文件夹中

  • 我不确定这是否重要。。。但我的别名末尾没有斜杠:

    别名/static/../....…/static


  • apache日志是否显示返回404的入站请求?是的,在我的
    access.log
    too中它们是404。您认为这是您的应用程序的编码问题吗?如果是配置问题,可能应该将其传输到
    serverfault
    ?我的静态文件在文件夹中,并且我尝试在没有运气的情况下删除后面的斜杠/static/文件夹应该属于组www data只是组还是用户和组?因为我现在将其作为两者,并且404www数据仍然是Apache所属的组。如果路径中的所有文件夹都属于组www数据,并且具有组的读取权限,则该文件夹应该可以工作(如果没有其他问题)