I'm new in the world of Django. I've been working on setting up WSGI to serve my Django project. It is working fine on my personal machine but on the server I'm having a hard time to setup.
I'm using logging in Django. But it is giving 'permission denied' error. But when I place all my log files in the '/tmp' folder, it works fine.
Similar issue is with the 'db.sqlite3' file (that is my DB file which the Django uses).
Please help me out in resolving the issue.
Following information may be useful to help me out :
OS : CentOS 7
Python : 2.7.5
Apache : 2.4.6
MOD_WSGI : 3.4
Following is the WSGI's error_log:
[Wed Aug 05 01:53:31.661156 2015] [:error] [pid 32177] [remote 192.168.40.142:184] Traceback (most recent call last):
[Wed Aug 05 01:53:31.661192 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/var/www/html/portals/wsgi.py", line 18, in <module>
[Wed Aug 05 01:53:31.661254 2015] [:error] [pid 32177] [remote 192.168.40.142:184] application = get_wsgi_application()
[Wed Aug 05 01:53:31.661274 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/var/www/html/venv/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Wed Aug 05 01:53:31.661313 2015] [:error] [pid 32177] [remote 192.168.40.142:184] django.setup()
[Wed Aug 05 01:53:31.661330 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/var/www/html/venv/lib/python2.7/site-packages/django/__init__.py", line 17, in setup
[Wed Aug 05 01:53:31.661361 2015] [:error] [pid 32177] [remote 192.168.40.142:184] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Wed Aug 05 01:53:31.661378 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/var/www/html/venv/lib/python2.7/site-packages/django/utils/log.py", line 86, in configure_logging
[Wed Aug 05 01:53:31.661451 2015] [:error] [pid 32177] [remote 192.168.40.142:184] logging_config_func(logging_settings)
[Wed Aug 05 01:53:31.661483 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/usr/lib64/python2.7/logging/config.py", line 803, in dictConfig
[Wed Aug 05 01:53:31.661519 2015] [:error] [pid 32177] [remote 192.168.40.142:184] dictConfigClass(config).configure()
[Wed Aug 05 01:53:31.661537 2015] [:error] [pid 32177] [remote 192.168.40.142:184] File "/usr/lib64/python2.7/logging/config.py", line 585, in configure
[Wed Aug 05 01:53:31.661584 2015] [:error] [pid 32177] [remote 192.168.40.142:184] '%r: %s' % (name, e))
[Wed Aug 05 01:53:31.661643 2015] [:error] [pid 32177] [remote 192.168.40.142:184] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/var/www/html/portals/logs/debug.log'
You need to fix permissions with the chmod command, like this:
chmod 775 /var/www/html/portals/logs/debug.log
chown username:apache /var/www/html/portals/logs/debug.log
If group is www-data,change apache to www-data
If the security not matters.You can try
chmod 777 /var/www/html/portals/logs/debug.log
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!
Today I upgraded my Ubuntu server (Digital Ocean Droplet) to 20.04 from 18.04. After upgrading, my Flask application getting WSGI error(s) and can't run the flask app. Here is the apache2 error log.
[Wed Sep 30 14:02:19.652956 2020] [wsgi:error] [pid 2335] [client 121.128.137.103:53959] SyntaxError: invalid syntax
[Wed Sep 30 14:02:31.864498 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] mod_wsgi (pid=2329): Failed to exec Python script file '/var/www/webApp/webapp.wsgi'.
[Wed Sep 30 14:02:31.864542 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] mod_wsgi (pid=2329): Exception occurred processing WSGI script '/var/www/webApp/webapp.wsgi'.
[Wed Sep 30 14:02:31.864566 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] Traceback (most recent call last):
[Wed Sep 30 14:02:31.864590 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] File "/var/www/webApp/webapp.wsgi", line 7, in <module>
[Wed Sep 30 14:02:31.864668 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] from webApp import app as application
[Wed Sep 30 14:02:31.864728 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] File "/var/www/webApp/webApp/__init__.py", line 326
[Wed Sep 30 14:02:31.864735 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] res = make_response(jsonify({"message": f" File Is Exceeded The Maximum Size Limit"}), 403)
[Wed Sep 30 14:02:31.864740 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] ^
[Wed Sep 30 14:02:31.864745 2020] [wsgi:error] [pid 2329] [client 121.128.137.103:53961] SyntaxError: invalid syntax
Here is the code inside the webapp.wsgi file
#!/usr/bin/python3
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/webApp/")
from webApp import app as application
application.secret_key = 'someSecret_k*eY'
Searched in Google and SO few hours but nothing found to fix the error. Can Someone tell me where is the error and a way to fixe this?.
I'm trying to deploy a python web app using django and have successfully setup the EB environment but for some reason, it's not using my requirements.txt file to install the required modules (django and pytz). I see no reference to an invalid requirements.txt so I don't think that's the issue. Here is a file hierarchy and the latest log.
FirstWebApp/
.elasticbeanstalk/
config.yml
mysite/
#..
polls/
#..
db.sqlite3
manage.py
requirements.txt
[Sat Sep 01 21:08:01.508757 2018] [mpm_prefork:notice] [pid 7866] AH00169: caught SIGTERM, shutting down
[Sat Sep 01 21:08:02.599699 2018] [suexec:notice] [pid 11160] AH01232: suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Sat Sep 01 21:08:02.615594 2018] [so:warn] [pid 11160] AH01574: module wsgi_module is already loaded, skipping
[Sat Sep 01 21:08:02.617699 2018] [http2:warn] [pid 11160] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
[Sat Sep 01 21:08:02.617712 2018] [http2:warn] [pid 11160] AH02951: mod_ssl does not seem to be enabled
[Sat Sep 01 21:08:02.618263 2018] [lbmethod_heartbeat:notice] [pid 11160] AH02282: No slotmem from mod_heartmonitor
[Sat Sep 01 21:08:02.618326 2018] [:warn] [pid 11160] mod_wsgi: Compiled for Python/3.6.2.
[Sat Sep 01 21:08:02.618331 2018] [:warn] [pid 11160] mod_wsgi: Runtime using Python/3.6.5.
[Sat Sep 01 21:08:02.620634 2018] [mpm_prefork:notice] [pid 11160] AH00163: Apache/2.4.33 (Amazon) mod_wsgi/3.5 Python/3.6.5 configured -- resuming normal operations
[Sat Sep 01 21:08:02.620651 2018] [core:notice] [pid 11160] AH00094: Command line: '/usr/sbin/httpd -D FOREGROUND'
[Sat Sep 01 21:08:05.381076 2018] [:error] [pid 11165] [remote 127.0.0.1:0] mod_wsgi (pid=11165): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Sat Sep 01 21:08:05.381116 2018] [:error] [pid 11165] [remote 127.0.0.1:0] mod_wsgi (pid=11165): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Sat Sep 01 21:08:05.381287 2018] [:error] [pid 11165] [remote 127.0.0.1:0] Traceback (most recent call last):
[Sat Sep 01 21:08:05.381309 2018] [:error] [pid 11165] [remote 127.0.0.1:0] File "/opt/python/current/app/mysite/wsgi.py", line 12, in <module>
[Sat Sep 01 21:08:05.381313 2018] [:error] [pid 11165] [remote 127.0.0.1:0] from django.core.wsgi import get_wsgi_application
[Sat Sep 01 21:08:05.381326 2018] [:error] [pid 11165] [remote 127.0.0.1:0] ModuleNotFoundError: No module named 'django'
[Sat Sep 01 21:08:06.384353 2018] [:error] [pid 11165] [remote 127.0.0.1:252] mod_wsgi (pid=11165): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Sat Sep 01 21:08:06.384403 2018] [:error] [pid 11165] [remote 127.0.0.1:252] mod_wsgi (pid=11165): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Sat Sep 01 21:08:06.384505 2018] [:error] [pid 11165] [remote 127.0.0.1:252] Traceback (most recent call last):
[Sat Sep 01 21:08:06.384528 2018] [:error] [pid 11165] [remote 127.0.0.1:252] File "/opt/python/current/app/mysite/wsgi.py", line 12, in <module>
[Sat Sep 01 21:08:06.384531 2018] [:error] [pid 11165] [remote 127.0.0.1:252] from django.core.wsgi import get_wsgi_application
[Sat Sep 01 21:08:06.384560 2018] [:error] [pid 11165] [remote 127.0.0.1:252] ModuleNotFoundError: No module named 'django'
[Sat Sep 01 21:08:07.387609 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] mod_wsgi (pid=11165): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Sat Sep 01 21:08:07.387656 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] mod_wsgi (pid=11165): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Sat Sep 01 21:08:07.387725 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] Traceback (most recent call last):
[Sat Sep 01 21:08:07.387744 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] File "/opt/python/current/app/mysite/wsgi.py", line 12, in <module>
[Sat Sep 01 21:08:07.387748 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] from django.core.wsgi import get_wsgi_application
[Sat Sep 01 21:08:07.387761 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] ModuleNotFoundError: No module named 'django'
[Sat Sep 01 21:08:08.390656 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] mod_wsgi (pid=11165): Target WSGI script '/opt/python/current/app/mysite/wsgi.py' cannot be loaded as Python module.
[Sat Sep 01 21:08:08.390700 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] mod_wsgi (pid=11165): Exception occurred processing WSGI script '/opt/python/current/app/mysite/wsgi.py'.
[Sat Sep 01 21:08:08.390770 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] Traceback (most recent call last):
[Sat Sep 01 21:08:08.390790 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] File "/opt/python/current/app/mysite/wsgi.py", line 12, in <module>
[Sat Sep 01 21:08:08.390793 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] from django.core.wsgi import get_wsgi_application
[Sat Sep 01 21:08:08.390807 2018] [:error] [pid 11165] [remote 127.0.0.1:2304] ModuleNotFoundError: No module named 'django'
I just had to commit the requirements.txt file. Django only looks at whatever files have been committed.
I am using boto3 for communicating with AWS S3. I first tried with my local system. It successfully got connected and was working fine. I moved the code to the server(flask-apache2). Now the code is not working. It shows ProfileNotFound: The config profile (dev) could not be found exception even though I set the the parameters over ~/.aws/credentials and ~/.aws/config
~/.aws/credentials file:
[dev]
aws_access_key_id = *****************
aws_secret_access_key = *********************
~/.aws/config file:
[default]
region = us-west-2
output = json
[profile dev]
region = us-west-2
output = json
This is how I am accessing the profile:
session = boto3.Session(profile_name='dev')
s3 = session.resource('s3')
Error Log:
session = boto3.Session(profile_name='dev')
[Wed Jun 21 05:50:56.912720 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] File "/usr/local/lib/python2.7/dist-packages/boto3/session.py", line 80, in __init__
[Wed Jun 21 05:50:56.912836 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] self._setup_loader()
[Wed Jun 21 05:50:56.912866 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] File "/usr/local/lib/python2.7/dist-packages/boto3/session.py", line 120, in _setup_loader
[Wed Jun 21 05:50:56.912893 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] self._loader = self._session.get_component('data_loader')
[Wed Jun 21 05:50:56.912910 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 701, in get_component
[Wed Jun 21 05:50:56.913104 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] return self._components.get_component(name)
[Wed Jun 21 05:50:56.913121 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 897, in get_component
[Wed Jun 21 05:50:56.913134 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] self._components[name] = factory()
[Wed Jun 21 05:50:56.913145 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 181, in <lambda>
[Wed Jun 21 05:50:56.913154 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] lambda: create_loader(self.get_config_variable('data_path')))
[Wed Jun 21 05:50:56.913163 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 265, in get_config_variable
[Wed Jun 21 05:50:56.913172 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] elif self._found_in_config_file(methods, var_config):
[Wed Jun 21 05:50:56.913181 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 286, in _found_in_config_file
[Wed Jun 21 05:50:56.913190 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] return var_config[0] in self.get_scoped_config()
[Wed Jun 21 05:50:56.913198 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] File "/usr/local/lib/python2.7/dist-packages/botocore/session.py", line 358, in get_scoped_config
[Wed Jun 21 05:50:56.913206 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] raise ProfileNotFound(profile=profile_name)
[Wed Jun 21 05:50:56.913225 2017] [wsgi:error] [pid 21586] [remote 103.227.98.117:37564] ProfileNotFound: The config profile (dev) could not be found
Finally, I found the solution!
I added the AWS Credentials & Config file paths to apache2 envvars file. And the problem got solved.
Steps:
$sudo nano /etc/apache2/envvars
# Added the following lines
export AWS_CONFIG_FILE=/home/ubuntu/.aws/config
export AWS_SHARED_CREDENTIALS_FILE=/home/ubuntu/.aws/credentials
sudo service apache2 reload | sudo service apache2 restart
Done! It started working fine!!
I initially tried adding like AWS_CONFIG_FILE=~/.aws/credentials. This didn't work. Have to give the complete path.
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.