title: Apache + Django + WSGI : Page is not working
body: <p>i don't understand why my apache server doesn't work. When i try to connect to the address <a href="http://bde.yggdrasil.cafe" rel="nofollow noreferrer">http://bde.yggdrasil.cafe</a> with opera i have the following message <code>This page isn't working bde.yggdrasil.cafe is currently unable to handle this request.</code> i i don't undrstand why.</p>
  
  <p>I enables <code>mod_wsgi</code> in <code>/etc/httpd/conf/http.conf</code></p>
  
  <p>Here is the config file I import in my main config : </p>
  
  <pre><code>$ cat  /etc/httpd/conf/extra/bdeweb.conf
  &lt;VirtualHost *:80&gt;
      # This is name based virtual hosting. So place an appropriate server name
      #   here. Example: django.devsrv.local
      ServerName  bde.yggdrasil.cafe
      ServerAdmin     my@email.fr
      DocumentRoot    /srv/http/bdeweb
  
      # This alias makes serving static files possible.
      #   Please note, that this is geared to our settings/common.py
      #   In production environment, you will propably adjust this!
      Alias /static/  /hdd/bdeweb/static
  
      # This alias makes serving media files possible.
      #   Please note, that this is geared to our settings/common.py
      #   In production environment, you will propably adjust this!
      Alias /media/   /srv/http/bdeweb/media
  
      # Insert the full path to the wsgi.py-file here
      WSGIScriptAlias /   /srv/http/bdeweb/bdewebsite/wsgi.py
  
  
  
      # PROCESS_NAME specifies a distinct name of this process
      #   see: https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIDaemonProcess
      # PATH/TO/PROJECT_ROOT is the full path to your project's root directory, 
      #   containing your project files
      # PATH/TO/VIRTUALENV/ROOT: If you are using a virtualenv specify the full
      #   path to its directory.
      #   Generally you must specify the path to Python's site-packages.
      #WSGIDaemonProcess   bdewebsite  python-path=/srv/http/bdeweb python-home=/usr/bin/python3
  
      # PROCESS_GROUP specifies a distinct name for the process group
      #   see: https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIProcessGroup
      WSGIProcessGroup     bdewebsite
  
      &lt;Directory /srv/http/bdeweb/bdewebsite&gt;
          &lt;Files wsgi.py&gt;
              Require all granted
          &lt;/Files&gt;
      &lt;/Directory&gt;
  
      # Serving static files from this directory
      #   Please note, that this is geared to our settings/common.py
      #   In production environment, you will propably adjust this!
      &lt;Directory /hdd/bdeweb/static&gt;
          Require all granted
      &lt;/Directory&gt;
  
      # Serving media files from this directory
      #   Please note, that this is geared to our settings/common.py
      #   In production environment, you will propably adjust this!
      &lt;Directory /srv/http/bdeweb/media&gt;
          Require all granted
      &lt;/Directory&gt;
  
      LogLevel debug
  
      # PROJECT_NAME is used to seperate the log files of this application
      ErrorLog    ${APACHE_LOG_DIR}/bdeweb_error.log
      CustomLog   ${APACHE_LOG_DIR}/bdeweb_access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>My server i well started with no errors :</p>
  
  <pre><code>$ sudo systemctl restart httpd &amp;&amp; systemctl -l status httpd
  * httpd.service - Apache Web Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
     Active: active (running) since Tue 2017-10-31 10:55:38 UTC; 51ms ago
    Process: 11938 ExecStop=/usr/bin/httpd -k graceful-stop (code=exited, status=0/SUCCESS)
   Main PID: 11943 (httpd)
      Tasks: 1 (limit: 4915)
     CGroup: /system.slice/httpd.service
             `-11943 /usr/bin/httpd -k start -DFOREGROUND
  
  Oct 31 10:55:38 Yggdrasil systemd[1]: Started Apache Web Server.
  </code></pre>
  
  <p>An i have no errors in journactl :</p>
  
  <pre><code>$ journalctl -xe
  [...]
  -- Subject: Unit httpd.service has begun shutting down
  -- Defined-By: systemd
  -- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
  -- 
  -- Unit httpd.service has begun shutting down.
  Oct 31 10:55:38 Yggdrasil systemd[1]: httpd.service: Killing process 11851 (httpd) with signal SIGKILL.
  Oct 31 10:55:38 Yggdrasil systemd[1]: httpd.service: Killing process 11852 (httpd) with signal SIGKILL.
  Oct 31 10:55:38 Yggdrasil systemd[1]: httpd.service: Killing process 11853 (httpd) with signal SIGKILL.
  Oct 31 10:55:38 Yggdrasil systemd[1]: httpd.service: Killing process 11854 (httpd) with signal SIGKILL.
  Oct 31 10:55:38 Yggdrasil systemd[1]: httpd.service: Killing process 11855 (httpd) with signal SIGKILL.
  Oct 31 10:55:38 Yggdrasil systemd[1]: httpd.service: Killing process 11908 (httpd) with signal SIGKILL.
  Oct 31 10:55:38 Yggdrasil systemd[1]: Stopped Apache Web Server.
  -- Subject: Unit httpd.service has finished shutting down
  -- Defined-By: systemd
  -- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
  -- 
  -- Unit httpd.service has finished shutting down.
  Oct 31 10:55:38 Yggdrasil systemd[1]: Started Apache Web Server.
  -- Subject: Unit httpd.service has finished start-up
  -- Defined-By: systemd
  -- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
  -- 
  -- Unit httpd.service has finished starting up.
  -- 
  -- The start-up result is RESULT.
  Oct 31 10:55:38 Yggdrasil sudo[11935]: pam_unix(sudo:session): session closed for user root
  </code></pre>
  
  <p>EDIT 1 : My error log is also empty :</p>
  
  <pre><code>$ cat /var/log/httpd/bdeweb_error.log
  $
  </code></pre>
  
  <p>EDIT 2 : If i uncoment the line <code>WSGIDaemonProcess</code> i have the following error in apache error logs:</p>
  
  <pre><code> mod_wsgi (pid=12450): Target WSGI script '/srv/http/bdeweb/bdewebsite/wsgi.py' cannot be loaded as Python module.
   mod_wsgi (pid=12450): Exception occurred processing WSGI script '/srv/http/bdeweb/bdewebsite/wsgi.py'.
   Traceback (most recent call last):
     File "/srv/http/bdeweb/bdewebsite/wsgi.py", line 16, in &lt;module&gt;
       application = get_wsgi_application()
     File "/usr/lib/python3.6/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
       django.setup(set_prefix=False)
     File "/usr/lib/python3.6/site-packages/django/__init__.py", line 22, in setup
       configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
     File "/usr/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
       self._setup(name)
     File "/usr/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
       self._wrapped = Settings(settings_module)
     File "/usr/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
       mod = importlib.import_module(self.SETTINGS_MODULE)
     File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
       return _bootstrap._gcd_import(name[level:], package, level)
     File "&lt;frozen importlib._bootstrap&gt;", line 978, in _gcd_import
     File "&lt;frozen importlib._bootstrap&gt;", line 961, in _find_and_load
     File "&lt;frozen importlib._bootstrap&gt;", line 936, in _find_and_load_unlocked
     File "&lt;frozen importlib._bootstrap&gt;", line 205, in _call_with_frames_removed
     File "&lt;frozen importlib._bootstrap&gt;", line 978, in _gcd_import
     File "&lt;frozen importlib._bootstrap&gt;", line 961, in _find_and_load
     File "&lt;frozen importlib._bootstrap&gt;", line 948, in _find_and_load_unlocked
   ModuleNotFoundError: No module named 'bdewebsite'
  </code></pre>
  
  <p>What have i done wrong ?</p>
  
  <h2>Solution</h2>
  
  <p>I had to remove <code>python-home=/usr/bin/python3</code>from WSGIDaemonProcess and i changed the name of the process group.</p>