i followed AWS tutorial for django lightsail instance: https://aws.amazon.com/es/getting-started/hands-on/deploy-python-application/
i tried to deploy my own code but apache gives me errors on piped installed modules.
It seems that instance have different paths. Some one has deployed custom django projects on django lightsail instance?
[Sun Aug 16 22:58:29.402644 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] mod_wsgi (pid=4065): Exception occurred processing WSGI script '/opt/bitnami/apps/django/django_projects/orderbot/ordermenu/wsgi.py'.
[Sun Aug 16 22:58:29.403437 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] Traceback (most recent call last):
[Sun Aug 16 22:58:29.403493 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "/opt/bitnami/apps/django/django_projects/orderbot/ordermenu/wsgi.py", line 22, in <module>
[Sun Aug 16 22:58:29.403504 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] application = get_wsgi_application()
[Sun Aug 16 22:58:29.403515 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "/opt/bitnami/python/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Sun Aug 16 22:58:29.403521 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] django.setup(set_prefix=False)
[Sun Aug 16 22:58:29.403530 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "/opt/bitnami/python/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
[Sun Aug 16 22:58:29.403535 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] apps.populate(settings.INSTALLED_APPS)
[Sun Aug 16 22:58:29.403544 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "/opt/bitnami/python/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
[Sun Aug 16 22:58:29.403549 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] app_config = AppConfig.create(entry)
[Sun Aug 16 22:58:29.403558 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "/opt/bitnami/python/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
[Sun Aug 16 22:58:29.403563 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] module = import_module(entry)
[Sun Aug 16 22:58:29.403571 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "/opt/bitnami/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
[Sun Aug 16 22:58:29.403578 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] return _bootstrap._gcd_import(name[level:], package, level)
[Sun Aug 16 22:58:29.403587 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
[Sun Aug 16 22:58:29.403596 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "<frozen importlib._bootstrap>", line 991, in _find_and_load
[Sun Aug 16 22:58:29.403606 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
[Sun Aug 16 22:58:29.403626 2020] [wsgi:error] [pid 4065] [client 177.240.102.67:65250] ModuleNotFoundError: No module named 'phonenumber_field'
The problem is that 'python install packages in a directory that apache do not see'.
so: packages get installed in '/home/bitnami/.local/lib/python3.8/site-packages/' and Apache looks in '/opt/bitnami/python/lib/python3.8/site-packages/'.
The temporary solution I followed is copying packages to Apache eyes folder with this command 'cp -r /home/bitnami/.local/lib/python3.8/site-packages/* /opt/bitnami/python/lib/python3.8/site-packages/'
Just needed to use the root user with sudo su command for pip install packages, now are found by apache.
Related
I've joined the unhappy ranks of people who have tried to set up a Django website served by Apache (on Amazon-linux EC2).
I have successfully configured Apache and compiled mod_wsgi against Python3.4 using a virtualenv (at /home/ec2-user/web-dev) largely following instructions at https://gist.github.com/tanuka72/79ae58b16be4ac3fafe0 and the mod_wsgi docs).
However, I get an Internal Server Error when loading the Django test app.
Looking at the logs, it seems that multiple versions of Python are somehow being called during the processing (see the change from /home/ec2-user/web-dev/lib64/python3.4 to /usr/lib64/python3.7). Also it seems that mod_wsgi cannot be imported (whilst 'import mod_wsgi' works fine from a python prompt in the ec2 terminal).
[Thu Jan 19 15:19:27.329376 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] mod_wsgi (pid=9955): Failed to exec Python script file '/var/www/test/test_site/test_site/wsgi.py'.
[Thu Jan 19 15:19:27.329445 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] mod_wsgi (pid=9955): Exception occurred processing WSGI script '/var/www/test/test_site/test_site/wsgi.py'.
[Thu Jan 19 15:19:27.330049 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] Traceback (most recent call last):
[Thu Jan 19 15:19:27.330088 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "/var/www/test/test_site/test_site/wsgi.py", line 25, in <module>
[Thu Jan 19 15:19:27.330093 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] application = get_wsgi_application()
[Thu Jan 19 15:19:27.330108 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "/home/ec2-user/web-dev/lib64/python3.4/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Thu Jan 19 15:19:27.330112 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] django.setup(set_prefix=False)
[Thu Jan 19 15:19:27.330117 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "/home/ec2-user/web-dev/lib64/python3.4/site-packages/django/__init__.py", line 24, in setup
[Thu Jan 19 15:19:27.330121 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] apps.populate(settings.INSTALLED_APPS)
[Thu Jan 19 15:19:27.330126 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "/home/ec2-user/web-dev/lib64/python3.4/site-packages/django/apps/registry.py", line 89, in populate
[Thu Jan 19 15:19:27.330129 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] app_config = AppConfig.create(entry)
[Thu Jan 19 15:19:27.330134 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "/home/ec2-user/web-dev/lib64/python3.4/site-packages/django/apps/config.py", line 123, in create
[Thu Jan 19 15:19:27.330137 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] import_module(entry)
[Thu Jan 19 15:19:27.330142 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "/usr/lib64/python3.7/importlib/__init__.py", line 127, in import_module
[Thu Jan 19 15:19:27.330146 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] return _bootstrap._gcd_import(name[level:], package, level)
[Thu Jan 19 15:19:27.330151 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
[Thu Jan 19 15:19:27.330156 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "<frozen importlib._bootstrap>", line 983, in _find_and_load
[Thu Jan 19 15:19:27.330161 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] File "<frozen importlib._bootstrap>", line 962, in _find_and_load_unlocked
[Thu Jan 19 15:19:27.330176 2023] [wsgi:error] [pid 9955] [remote 81.109.251.90:61582] ModuleNotFoundError: No module named 'mod_wsgi.server'; 'mod_wsgi' is not a package
To debug this, I wanted to see which version of python was being called. Overriding wsgi.py to remove the call to Django's get_wsgi_application prevents the error. The URL shows the results of the application function below:
# In test_site/test_site/wsgi.py:
# ...
python_home = '/home/ec2-user/web-dev'
activator = python_home + '/bin/activate_this.py'
with open(activator) as f:
exec(f.read(), {'__file__': activator})
import os
import sys
from django.core.wsgi import get_wsgi_application
sys.path.append('/var/www/test/test_site')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'test_site.settings')
#application = get_wsgi_application()
def application(environ, start_response):
status = '200 OK'
msg = f"sys.path: {sys.path} | sys.prefix: {sys.prefix} | sys.executable: {sys.executable} | Python version {sys.version}"
output = str.encode(msg)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
The function has a confusing output in the browser:
sys.path: ['/home/ec2-user/web-dev/lib64/python3.4/site-packages', '/home/ec2-user/web-dev/lib/python3.4/site-packages', '/var/www/test/test_site/test_site/wsgi.py', '/usr/lib64/python37.zip', '/usr/lib64/python3.7', '/usr/lib64/python3.7/lib-dynload', '/var/www/test/test_site', '/var/www/test/test_site', '/var/www/test/test_site'] | sys.prefix: /home/ec2-user/web-dev | sys.executable: /home/ec2-user/web-dev/bin/python | Python version 3.7.15 (default, Oct 31 2022, 22:44:31)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-15)]
There are more folders in the PYTHONPATH than I expected, and also Python 3.7 appears to be running instead of 3.4. Interestingly this shows that mod_wsgi is working.
For reference, my httpd.conf file is updated to include:
WSGIScriptAlias / /var/www/test/test_site/test_site/wsgi.py
WSGIPythonPath /var/www/test:/home/ec2-user/web-dev/lib/python3.4/site-packages:/home/ec2-user/web-dev/lib64/python3.4/site-packages
<Directory /var/www/test/test_site/test_site>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
What can I do to get this Django app to load? This is only step one - before I try my own website, and adding a database too - it was only supposed to take a few hours. It has been a few days!
I'm tryign to get a Django application with Python 3.7 working with CentOS 7 and Apache (Mod WSGI). I have a project with a virtual environment set up. How do I turn off SqlLite? I'm not and don't intend to ever use it. I tried running
(dentalenv) [root#server Python-3.7.2]# sudo yum install libsqlite3-dev
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirror.us-midwest-1.nexcess.net
* epel: mirror.steadfastnet.com
* extras: mirror.us-midwest-1.nexcess.net
* updates: mirror.us-midwest-1.nexcess.net
No package libsqlite3-dev available.
Error: Nothing to do
to install it and then restarting my Apache server. I even rebuilt Python, but I still get the below error, "ModuleNotFoundError: No module named '_sqlite3'"
[Wed Feb 20 04:03:06.627020 2019] [wsgi:error] [pid 11885] Traceback (most recent call last):
[Wed Feb 20 04:03:06.627285 2019] [wsgi:error] [pid 11885] File "/var/www/html/dental/wsgi.py", line 25, in <module>
[Wed Feb 20 04:03:06.627323 2019] [wsgi:error] [pid 11885] application = get_wsgi_application()
[Wed Feb 20 04:03:06.627353 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
[Wed Feb 20 04:03:06.627378 2019] [wsgi:error] [pid 11885] django.setup(set_prefix=False)
[Wed Feb 20 04:03:06.627405 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
[Wed Feb 20 04:03:06.627429 2019] [wsgi:error] [pid 11885] apps.populate(settings.INSTALLED_APPS)
[Wed Feb 20 04:03:06.627467 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/apps/registry.py", line 112, in populate
[Wed Feb 20 04:03:06.627493 2019] [wsgi:error] [pid 11885] app_config.import_models()
[Wed Feb 20 04:03:06.627520 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/apps/config.py", line 198, in import_models
[Wed Feb 20 04:03:06.627544 2019] [wsgi:error] [pid 11885] self.models_module = import_module(models_module_name)
[Wed Feb 20 04:03:06.627571 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
[Wed Feb 20 04:03:06.627608 2019] [wsgi:error] [pid 11885] return _bootstrap._gcd_import(name[level:], package, level)
[Wed Feb 20 04:03:06.627636 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
[Wed Feb 20 04:03:06.627666 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 983, in _find_and_load
[Wed Feb 20 04:03:06.627695 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
[Wed Feb 20 04:03:06.627724 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
[Wed Feb 20 04:03:06.627754 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap_external>", line 728, in exec_module
[Wed Feb 20 04:03:06.627783 2019] [wsgi:error] [pid 11885] File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
[Wed Feb 20 04:03:06.627812 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/contrib/auth/models.py", line 2, in <module>
[Wed Feb 20 04:03:06.627835 2019] [wsgi:error] [pid 11885] from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
[Wed Feb 20 04:03:06.627861 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 47, in <module>
[Wed Feb 20 04:03:06.627884 2019] [wsgi:error] [pid 11885] class AbstractBaseUser(models.Model):
[Wed Feb 20 04:03:06.627910 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/models/base.py", line 101, in __new__
[Wed Feb 20 04:03:06.627933 2019] [wsgi:error] [pid 11885] new_class.add_to_class('_meta', Options(meta, app_label))
[Wed Feb 20 04:03:06.627958 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/models/base.py", line 305, in add_to_class
[Wed Feb 20 04:03:06.627981 2019] [wsgi:error] [pid 11885] value.contribute_to_class(cls, name)
[Wed Feb 20 04:03:06.628008 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/models/options.py", line 203, in contribute_to_class
[Wed Feb 20 04:03:06.628031 2019] [wsgi:error] [pid 11885] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Wed Feb 20 04:03:06.628058 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/__init__.py", line 33, in __getattr__
[Wed Feb 20 04:03:06.628081 2019] [wsgi:error] [pid 11885] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Wed Feb 20 04:03:06.628107 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/utils.py", line 202, in __getitem__
[Wed Feb 20 04:03:06.628132 2019] [wsgi:error] [pid 11885] backend = load_backend(db['ENGINE'])
[Wed Feb 20 04:03:06.628159 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/utils.py", line 110, in load_backend
[Wed Feb 20 04:03:06.628193 2019] [wsgi:error] [pid 11885] return import_module('%s.base' % backend_name)
[Wed Feb 20 04:03:06.628222 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/importlib/__init__.py", line 127, in import_module
[Wed Feb 20 04:03:06.628243 2019] [wsgi:error] [pid 11885] return _bootstrap._gcd_import(name[level:], package, level)
[Wed Feb 20 04:03:06.628264 2019] [wsgi:error] [pid 11885] File "/var/www/html/dentalenv/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 10, in <module>
[Wed Feb 20 04:03:06.628283 2019] [wsgi:error] [pid 11885] from sqlite3 import dbapi2 as Database
[Wed Feb 20 04:03:06.628304 2019] [wsgi:error] [pid 11885] File "/usr/local/lib/python3.7/sqlite3/__init__.py", line 23, in <module>
[Wed Feb 20 04:03:06.628323 2019] [wsgi:error] [pid 11885] from sqlite3.dbapi2 import *
[Wed Feb 20 04:03:06.628344 2019] [wsgi:error] [pid 11885] File "/usr/local/lib/python3.7/sqlite3/dbapi2.py", line 27, in <module>
[Wed Feb 20 04:03:06.628369 2019] [wsgi:error] [pid 11885] from _sqlite3 import *
[Wed Feb 20 04:03:06.628408 2019] [wsgi:error] [pid 11885] ModuleNotFoundError: No module named '_sqlite3'
[Wed Feb 20 04:03:09.130480 2019] [wsgi:error] [pid 11885] [remote 207.181.224.155:58106] mod_wsgi (pid=11885): Target WSGI script '/var/www/html/dental/wsgi.py' does not contain WSGI application 'application'.
hey I'm trying to deploy my first django app on aws beanstalk
but I'm getting an :
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at root#localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
I'm following this tutorial:
https://realpython.com/deploying-a-django-app-to-aws-elastic-beanstalk/
I use python 3.6 and django 1.11
I just create a blank django project
part of log
-------------------------------------
/var/log/httpd/error_log
-------------------------------------
[Mon May 21 18:37:58.898238 2018] [:error] [pid 3353] [remote 172.31.30.216:17272] ModuleNotFoundError: No module named 'alpha_app.settings'
[Mon May 21 18:38:13.914282 2018] [:error] [pid 3353] [remote 172.31.30.216:120] mod_wsgi (pid=3353): Target WSGI script '/opt/python/current/app/alpha_app/alpha_app/wsgi.py' cannot be loaded as Python module.
[Mon May 21 18:38:13.914343 2018] [:error] [pid 3353] [remote 172.31.30.216:120] mod_wsgi (pid=3353): Exception occurred processing WSGI script '/opt/python/current/app/alpha_app/alpha_app/wsgi.py'.
[Mon May 21 18:38:13.914484 2018] [:error] [pid 3353] [remote 172.31.30.216:120] Traceback (most recent call last):
[Mon May 21 18:38:13.914527 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "/opt/python/current/app/alpha_app/alpha_app/wsgi.py", line 16, in <module>
[Mon May 21 18:38:13.914531 2018] [:error] [pid 3353] [remote 172.31.30.216:120] application = get_wsgi_application()
[Mon May 21 18:38:13.914547 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Mon May 21 18:38:13.914550 2018] [:error] [pid 3353] [remote 172.31.30.216:120] django.setup(set_prefix=False)
[Mon May 21 18:38:13.914556 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/__init__.py", line 22, in setup
[Mon May 21 18:38:13.914559 2018] [:error] [pid 3353] [remote 172.31.30.216:120] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon May 21 18:38:13.914563 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
[Mon May 21 18:38:13.914566 2018] [:error] [pid 3353] [remote 172.31.30.216:120] self._setup(name)
[Mon May 21 18:38:13.914571 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
[Mon May 21 18:38:13.914574 2018] [:error] [pid 3353] [remote 172.31.30.216:120] self._wrapped = Settings(settings_module)
[Mon May 21 18:38:13.914578 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "/opt/python/run/venv/local/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
[Mon May 21 18:38:13.914581 2018] [:error] [pid 3353] [remote 172.31.30.216:120] mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon May 21 18:38:13.914585 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "/opt/python/run/venv/lib64/python3.6/importlib/__init__.py", line 126, in import_module
[Mon May 21 18:38:13.914588 2018] [:error] [pid 3353] [remote 172.31.30.216:120] return _bootstrap._gcd_import(name[level:], package, level)
[Mon May 21 18:38:13.914593 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[Mon May 21 18:38:13.914598 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[Mon May 21 18:38:13.914602 2018] [:error] [pid 3353] [remote 172.31.30.216:120] File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
[Mon May 21 18:38:13.914617 2018] [:error] [pid 3353] [remote 172.31.30.216:120] ModuleNotFoundError: No module named 'alpha_app.settings'
I think this error comes from the wsgi.py file
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "alpha_app.settings")
but i have no clue how to fix it
I have found the solution to my own problem.
I forgot to make an extra folder named .ebextensions
and kept everything in the folder .elasticbeanstalk
Apparently I can not read.
I just hope my mistake can save someone hours.
My Django app was working fine, but now I'm getting a server error, the last thing I did was a reboot to my Centos7 Server and now I'm getting this error:
and this are my logs I'm using apache:
[Thu Mar 30 14:04:10.571843 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Target WSGI script '/opt/btsystem/BTSystem/wsgi.py' cannot be loaded as Python module.
[Thu Mar 30 14:04:10.571991 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Exception occurred processing WSGI script '/opt/btsystem/BTSystem/wsgi.py'.
[Thu Mar 30 14:04:10.572263 2017] [:error] [pid 11335] [remote 10.221.50.100:24] Traceback (most recent call last):
[Thu Mar 30 14:04:10.572544 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/opt/btsystem/BTSystem/wsgi.py", line 16, in <module>
[Thu Mar 30 14:04:10.572795 2017] [:error] [pid 11335] [remote 10.221.50.100:24] application = get_wsgi_application()
[Thu Mar 30 14:04:10.572919 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu Mar 30 14:04:10.573054 2017] [:error] [pid 11335] [remote 10.221.50.100:24] django.setup(set_prefix=False)
[Thu Mar 30 14:04:10.573107 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/__init__.py", line 22, in setup
[Thu Mar 30 14:04:10.573170 2017] [:error] [pid 11335] [remote 10.221.50.100:24] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Thu Mar 30 14:04:10.573261 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/utils/log.py", line 75, in configure_logging
[Thu Mar 30 14:04:10.573312 2017] [:error] [pid 11335] [remote 10.221.50.100:24] logging_config_func(logging_settings)
[Thu Mar 30 14:04:10.573369 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 803, in dictConfig
[Thu Mar 30 14:04:10.573409 2017] [:error] [pid 11335] [remote 10.221.50.100:24] dictConfigClass(config).configure()
[Thu Mar 30 14:04:10.573455 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 585, in configure
[Thu Mar 30 14:04:10.573501 2017] [:error] [pid 11335] [remote 10.221.50.100:24] '%r: %s' % (name, e))
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Any idea?
The last line shows that Django doesn't have permission to write to the configured log file.
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Make sure the file /opt/btsystem-logs/btsystem-debug.log is writeable by the user running the Django server.
The main problem was that I needed to do the following to enable the virtual host from Apache:
firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Needed to open the ports.
I have an issue with haystack https://stackoverflow.com/q/33669864/4910881 that requires me to uninstall it for now. I commented out haystack from installed apps expecting it will start throwing django import errors or similar errors but it still returning an internal server error.
[Thu Nov 12 15:32:03.579793 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] for conn in connections.all():
[Thu Nov 12 15:32:03.579802 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 112, in all
[Thu Nov 12 15:32:03.579815 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] return [self[alias] for alias in self.connections_info]
[Thu Nov 12 15:32:03.579823 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 100, in __getitem__
[Thu Nov 12 15:32:03.579836 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] self._connections[key] = load_backend(self.connections_info[key]['ENGINE'])(using=key)
[Thu Nov 12 15:32:03.579844 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 53, in load_backend
[Thu Nov 12 15:32:03.579857 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] return import_class(full_backend_path)
[Thu Nov 12 15:32:03.579865 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 23, in import_class
[Thu Nov 12 15:32:03.579878 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] raise ImportError("The Python module '%s' has no '%s' class." % (module_path, class_name))
[Thu Nov 12 15:32:03.579894 2015] [wsgi:error] [pid 191252:tid 139675802625792] [remote 127.0.0.1:196] ImportError: The Python module 'xapian_backend' has no 'XapianEngine' class.
[Thu Nov 12 15:32:03.626881 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] mod_wsgi (pid=191252): Exception occurred processing WSGI script '/home/kbuzz/webapps/revised/kb/kb/wsgi.py'.
[Thu Nov 12 15:32:03.626926 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] Traceback (most recent call last):
[Thu Nov 12 15:32:03.626950 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/django/core/handlers/wsgi.py", line 175, in __call__
[Thu Nov 12 15:32:03.626989 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] signals.request_started.send(sender=self.__class__)
[Thu Nov 12 15:32:03.627014 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/django/dispatch/dispatcher.py", line 198, in send
[Thu Nov 12 15:32:03.627041 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] response = receiver(signal=self, sender=sender, **named)
[Thu Nov 12 15:32:03.627057 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/__init__.py", line 59, in reset_search_queries
[Thu Nov 12 15:32:03.627082 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] for conn in connections.all():
[Thu Nov 12 15:32:03.627097 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 112, in all
[Thu Nov 12 15:32:03.627123 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] return [self[alias] for alias in self.connections_info]
[Thu Nov 12 15:32:03.627138 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 100, in __getitem__
[Thu Nov 12 15:32:03.627161 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] self._connections[key] = load_backend(self.connections_info[key]['ENGINE'])(using=key)
[Thu Nov 12 15:32:03.627176 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 53, in load_backend
[Thu Nov 12 15:32:03.627199 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] return import_class(full_backend_path)
[Thu Nov 12 15:32:03.627214 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] File "/home/kbuzz/lib/python2.7/haystack/utils/loading.py", line 23, in import_class
[Thu Nov 12 15:32:03.627237 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] raise ImportError("The Python module '%s' has no '%s' class." % (module_path, class_name))
[Thu Nov 12 15:32:03.627263 2015] [wsgi:error] [pid 191252:tid 139675918014208] [remote 127.0.0.1:11720] ImportError: The Python module 'xapian_backend' has no 'XapianEngine' class.
Try removing all related .pyc files