通过Apache加载Django静态文件

时间:2018-11-04 07:12:18

标签: django python-3.x apache centos7

我知道周围有很多这样的问题,我想我已经读完了,但是找不到我的问题。

我已经创建了一个名为 signIn(username: string, password: string): void { const authData = { Username: username, Password: password }; const authDetails = new AuthenticationDetails(authData); const userData = { Username: username, Pool: userPool }; const cognitoUser = new CognitoUser(userData); const that = this; cognitoUser.authenticateUser(authDetails, { onSuccess (result: CognitoUserSession) { console.log(result); }, onFailure(err) { console.log(err); } }); return; } 的文件,这就是我写的文件:

/etc/httpd/conf.d/django.conf

这是我在<VirtualHost *:8000> Alias /media/ /var/www/html/igame/media/ Alias /static/ /var/www/html/igame/static/ <Directory /var/www/html/igame/static> Require all granted </Directory> <Directory /var/www/html/igame/media> Require all granted </Directory> WSGIScriptAlias / /var/www/html/igame/igame/wsgi.py <Directory /var/www/html/igame/igame> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess igame python-path=/lib/python3.6/site-packages WSGIProcessGroup igame </VirtualHost> 中的静态设置:

settings.py

我已经跑过DEBUG = True STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') PROJECT_DIR = os.path.dirname(__file__)

但是当我用python3.6 manage.py collectstatic运行项目时,静态文件不会加载到我的项目中。

我使用python3.6 manage.py runserver 0.0.0.0:8000python 3.6django 2.1

我在这里想念什么?

更新

我安装了Apache 5.4,并按照this documents的建议将这些行添加到mod_wsgi

httpd.conf

并从WSGIScriptAlias / /var/www/html/igame/igame/wsgi.py <Directory /var/www/html/igame/igame> <Files wsgi.py> Require all granted </Files> </Directory> WSGIPythonHome /var/www/html/djangoenv WSGIPythonPath /var/www/html/igame WSGIDaemonProcess igame python-home=/var/www/html/djangoenv python-path=/var/www/html/igame WSGIProcessGroup igame 中删除了以下行:

django.conf

我通常使用WSGIDaemonProcess igame python-home=/var/www/html/djangoenv python-path=/var/www/html/igame WSGIProcessGroup igame 进行此操作,现在我真的很困惑如何使其与Apache一起使用。

0 个答案:

没有答案