smailt
August 30, 2021, 2:31pm
1
Hello,
my application didn’t work I don’t know where exactly I missed something in the configuration.
I am using Apache24 and mod-wsgi (4.9.0) both are installed
I tested the apache and ’ It works!’
I followed this tutorial to deploy Django;
https://www.youtube.com/watch?v=frEjX1DNSpc&t=1273s
in the configuration settings.py:
DEBUG = False
ALLOWED_HOSTS = ['localhost','127.0.0.1']
#
STATIC_URL = 'C:/WikiPED/Home/static/'
STATICFILES_DIRS =[
os.path.join(BASE_DIR,'C:/WikiPED/Home/static/'),]
TEMPLATE_DIRS = (os.path.join(BASE_DIR, 'C:/WikiPED/Home/templates/'),)
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'C:/WikiPED/Home/static')
and in the C:apache24/conf/httpd.conf I had added those lines:
ServerName 127.0.0.1:80
# Django Project
LoadFile "c:/python36/python36.dll"
LoadModule wsgi_module "c:/python36/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"
WSGIPythonHome "c:/python36"
WSGIScriptAlias / 'C:/WikiPED/WikiPed/wsgi.py'
WSGIPythonPath 'C:/WikiPED/'
<Directory 'C:/WikiPED/WikiPed/'>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static 'C:/WikiPED/Home/static/'
<Directory 'C:/WikiPED/Home/static/'>
Require all granted
</Directory>
So I’d run python manage.py collectstatic
and it works
so when I run the apache server it doesn’t start!?
and the pages 127.0.0.1 This site can’t be reached
what I missed here?
this is my project files organisation and locations
How are you running Apache? As a service or as a program?
What error messages are you getting in either your Apache log or the system log?
smailt
August 30, 2021, 2:50pm
3
KenWhitesell:
s a service or as a prog
as explained in the video I run CMD as administrator and from the apache24/bin folder
httpd.exe -k start
and no error is appeared just it doesn’t started
Then check the log files for errors.
smailt
August 30, 2021, 3:14pm
5
when I was trying to look for the log error, I just right click on the httpd.exe and run it as administrator
the application works , but still have a problem.
the problem is that the static files are not working correctly!
and it should be like this
any suggestions?
The STATIC_URL should be something like “/static/”:
smailt
August 30, 2021, 4:56pm
7
I’d changed it as it was in development step :
STATIC_URL = '/Home/static/'
STATICFILES_DIRS =[
os.path.join(BASE_DIR,'Home/static/'),]
TEMPLATE_DIRS = (os.path.join(BASE_DIR, '/Home/templates/'),)
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'Home/static')
CRISPY_TEMPLATE_PACK='bootstrap4'
LOGIN_REDIRECT_URL='EnentWorkOver'
LOGIN_URL ='login'
MEDIA_ROOT =os.path.join(BASE_DIR,'media/')
MEDIA_URL = '/media/'
and it copying the file into C:\Home\static?
and the httpd.conf is:
ServerName 127.0.0.1:80
# Django Project
LoadFile "c:/python36/python36.dll"
LoadModule wsgi_module "c:/python36/lib/site-packages/mod_wsgi/server/mod_wsgi.cp36-win_amd64.pyd"
WSGIPythonHome "c:/python36"
WSGIScriptAlias / 'C:/WikiPED/WikiPed/wsgi.py'
WSGIPythonPath 'C:/WikiPED/'
<Directory 'C:/WikiPED/WikiPed/'>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static 'C:/WikiPED/Home/static/'
<Directory 'C:/WikiPED/Home/static/'>
Require all granted
</Directory>
the same problem is does’t working (images, styles …)
What is the function of the STATIC_URL setting?
smailt
August 31, 2021, 7:23am
9
smailt:
STATIC_URL
I tried many solutions and I discovered that the problem is related to DEBUG function too.
so when the server manually with python manage.py runserver with DEBUG = True
it works good but if I change it as in production DEBUG = False the same problem back.
so using the apache server I’d do the same DEBUG = True and False, but both not working as expected and the images, styles…etc, aren’t collected.