1

I've got my project in /var/Django/Portfolio while having a virtualenv in /var/Django/env. It's just a new project without any changes except that I've set the DEBUG = False in the settings.py. Virtualenv has Django 1.9.15 and Python2.7 installed. When I run the project with the runserver on debug mode the site displays just fine, but when I try to deploy and open the site I get a 500 Internal Server Error. Looking at the log file it says ImportError: No module named settings

tail -f /var/log/apache2/error.log
[Mon Nov 21 19:04:51.009198 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Mon Nov 21 19:04:51.009538 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]   File "/var/www/Django/env/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
[Mon Nov 21 19:04:51.010080 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     self._setup(name)
[Mon Nov 21 19:04:51.010415 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]   File "/var/www/Django/env/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
[Mon Nov 21 19:04:51.011209 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     self._wrapped = Settings(settings_module)
[Mon Nov 21 19:04:51.011567 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]   File "/var/www/Django/env/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
[Mon Nov 21 19:04:51.012105 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     mod = importlib.import_module(self.SETTINGS_MODULE)
[Mon Nov 21 19:04:51.012454 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]   File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Mon Nov 21 19:04:51.013096 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0]     __import__(name)
[Mon Nov 21 19:04:51.013550 2016] [wsgi:error] [pid 8574:tid 2955441200] [remote 192.168.0.13:0] ImportError: No module named settings

Like I said I've changed nothing, just created the project with the startproject command.

My /etc/apache2/sites-enabled/000-default.conf file has the following settings added to it (was default before):

WSGIDaemonProcess folio python-path=/var/www/Django:/var/www/Django/env/lib/python2.7/site-packages
WSGIProcessGroup folio 
WSGIScriptAlias / /var/www/Django/Portfolio/Portfolio/wsgi.py
<Directory /var/www/Django/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>

This is my folder structure under var/www/:

.
.env/
./Portfolio/
./Portfolio./manage.py
./Portfolio./__init__.py
./Portfolio./Portfolio
./Portfolio./Portfolio/settings.pyc
./Portfolio./Portfolio/urls.py
./Portfolio./Portfolio/urls.pyc
./Portfolio./Portfolio/__init__.py
./Portfolio./Portfolio/settings.py
./Portfolio./Portfolio/wsgi.pyc
./Portfolio./Portfolio/__init__.pyc
./Portfolio./Portfolio/wsgi.py
./Portfolio./db.sqlite3
./Portfolio./__init__.pyc
Philip Feldmann
  • 7,887
  • 6
  • 41
  • 65
  • 1
    Could you include the whole error traceback in your question? – lucasnadalutti Nov 21 '16 at 19:10
  • Sure, I just thought it was redundant. I'll edit my post. – Philip Feldmann Nov 21 '16 at 19:17
  • 1
    Possible duplicate of http://stackoverflow.com/questions/7367577/django-shell-no-module-named-settings – Kevin_Kinsey Nov 21 '16 at 19:28
  • @Kevin_Kinsey thanks for your reply but I've tried that already. Changed the parent's folder name to DjangoPortfolio - still the same error though, so I just changed it back. – Philip Feldmann Nov 21 '16 at 19:29
  • 1
    What did you set ``DJANGO_SETTINGS_MODULE`` to? Just ``settings``? Normally it would have been ``Portfolio.settings`` and ``python-path`` option to ``WSGIDaemonProcess`` would include ``/var/www/Django/Portfolio``. If you have changed around typical Django project structure, could be different. So explain your file structure and what ``DJANGO_SETTINGS_MODULE`` is set to. – Graham Dumpleton Nov 21 '16 at 19:34
  • @GrahamDumpleton it's set to Portfolio.settings. I've tried setting the path of WSGIDaemonProcress like you mentioned it but I only got a "Bad Request 400" afterwards. I'll include my folder-structure in the original post. – Philip Feldmann Nov 21 '16 at 19:46
  • 1
    The bad request is likely different issue caused by not setting ``ALLOWED_HOSTS`` correctly. What do you have ``ALLOWED_HOSTS`` set to. You want it to be ``['*']``. – Graham Dumpleton Nov 21 '16 at 19:47
  • It was set to [] and I changed it to ["*"] now. I'm simply getting a "Not Found - The requested URL / was not found on this server." now. Sorry, I'm not very experienced with apache and this is the first time I'm trying to deploy a Django Project to it. Thank you for your patience. – Philip Feldmann Nov 21 '16 at 19:53
  • Any suggestion on that? – Philip Feldmann Nov 22 '16 at 13:08

0 Answers0