You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to deploy django rest framework on apache , and i did configure mod_wsgi with apache and did some changes to settings.py like static files and created virtualhost in apache , but im confusion right now , i don't know how i am suppose to access the api , when i try "curl 127.0.0.1:8001/django" i got the error below and when i try "curl 127.0.0.1:8001" i got client permission denied,.by the way I am using virtual environments,i install all the requirements on it , I guess the problem in execution wsgi.py but i don't know why ., maybe the default python is the problem even i am sure i installed mod-wsgi with python3.7 please check the last log .
here is the virtualhost :
<VirtualHost 127.0.0.1:8001 _default_:8001>
ServerAlias *
DocumentRoot /opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject
ServerAdmin yaz@gmail.com
# Set the path to your Django projec
WSGIDaemonProcess myproject python-path=/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject:/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject:/opt/bitnami/projects/chatbotQZ/sources/env/lib/python3.7/site-packages
WSGIProcessGroup myproject
WSGIScriptAlias /django /opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject/wsgi.py
# Configure access to static files
Alias /static/ /opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/static
<Directory /opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/static>
Require all granted
</Directory>
<Directory /opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject>
<Files wsgi.py>
Require all granted
</Files>
<Files "favicon.ico">
Require all granted
</Files>
</Directory>
ErrorLog /opt/bitnami/projects/chatbotQZ/sources/logs/drfapp_error.log
CustomLog /opt/bitnami/projects/chatbotQZ/sources/logs/drfapp_access.log combined
</VirtualHost>
Here is wsgi.py :
"""
WSGI config for myproject project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
application = get_wsgi_application()
here is the settings.py
"""
Django settings for myproject project.
Generated by 'django-admin startproject' using Django 3.2.18.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-=z(3%l&3lrwvz16411c!-kjqaeb#@644o4$cd&go!w0ymi6(30'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['chatbotwQz.localhost']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'base',
]
AUTH_USER_MODEL = 'base.user_auth'
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'myproject.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'myproject.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'chatbot',
'USER': 'root',
'PASSWORD': '',
'HOST': '127.0.0.1',
'PORT': '3306',
}
}
# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
this is the error log
[Thu Jul 06 11:42:31.220822 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] mod_wsgi (pid=4299): Failed to exec Python script file '/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject/wsgi.py'.
[Thu Jul 06 11:42:31.220857 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] mod_wsgi (pid=4299): Exception occurred processing WSGI script '/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject/wsgi.py'.
[Thu Jul 06 11:42:31.220879 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] Traceback (most recent call last):
[Thu Jul 06 11:42:31.220894 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] File "/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject/wsgi.py", line 12, in <module>
[Thu Jul 06 11:42:31.220936 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] from django.core.wsgi import get_wsgi_application
[Thu Jul 06 11:42:31.220946 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] File "/opt/bitnami/projects/chatbotQZ/sources/env/lib/python3.7/site-packages/django/__init__.py", line 1, in <module>
[Thu Jul 06 11:42:31.220977 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] from django.utils.version import get_version
[Thu Jul 06 11:42:31.220986 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] File "/opt/bitnami/projects/chatbotQZ/sources/env/lib/python3.7/site-packages/django/utils/version.py", line 7, in <module>
[Thu Jul 06 11:42:31.221024 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] from django.utils.regex_helper import _lazy_re_compile
[Thu Jul 06 11:42:31.221033 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] File "/opt/bitnami/projects/chatbotQZ/sources/env/lib/python3.7/site-packages/django/utils/regex_helper.py", line 10, in <module>
[Thu Jul 06 11:42:31.221092 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] from django.utils.functional import SimpleLazyObject
[Thu Jul 06 11:42:31.221101 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] File "/opt/bitnami/projects/chatbotQZ/sources/env/lib/python3.7/site-packages/django/utils/functional.py", line 362, in <module>
[Thu Jul 06 11:42:31.221165 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] class SimpleLazyObject(LazyObject):
[Thu Jul 06 11:42:31.221178 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] TypeError: Error when calling the metaclass bases
[Thu Jul 06 11:42:31.221183 2023] [wsgi:error] [pid 4299] [remote 127.0.0.1:35000] 'property' object is not callable
and this is result of curl 127.0.0.1:8001
this result when i run curl 127.0.0.1:8001/django
Even im sure i used python3.7 to install mod_wsgi i found this in error log of apache:
`Apache/2.4.54 (Unix) OpenSSL/1.1.1s mod_wsgi/4.9.4 Python/2.7 PHP/8.1.12 configured -- resuming normal operations`
The text was updated successfully, but these errors were encountered:
the-yaz
changed the title
mod_wsgi (pid=5953): Failed to exec Python script file '/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject/wsgi.py'. mod_wsgi (pid=5953): Exception occurred processing WSGI script '/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject/wsgi.py'.
Failed to exec Python script file '/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject/wsgi.py'. mod_wsgi (pid=5953): Exception occurred processing WSGI script '/opt/bitnami/projects/chatbotQZ/sources/team_city/myproject/myproject/wsgi.py'.
Jul 6, 2023
I'm trying to deploy django rest framework on apache , and i did configure mod_wsgi with apache and did some changes to settings.py like static files and created virtualhost in apache , but im confusion right now , i don't know how i am suppose to access the api , when i try "curl 127.0.0.1:8001/django" i got the error below and when i try "curl 127.0.0.1:8001" i got client permission denied,.by the way I am using virtual environments,i install all the requirements on it , I guess the problem in execution wsgi.py but i don't know why ., maybe the default python is the problem even i am sure i installed mod-wsgi with python3.7 please check the last log .
here is the virtualhost :
Here is wsgi.py :
here is the settings.py
this is the error log
The text was updated successfully, but these errors were encountered: