title: Django - Apache2 Internal Server Error
body: <p>I created a django project under <code>/home/toto/Desktop</code> named <code>dash_test</code> and I wanted to serve my Django application with Apache2 and mod_wsgi.</p>
  
  <p>I installed the Apache web server, the mod_wsgi, and pip using this command <code>sudo apt-get install python-pip apache2 libapache2-mod-wsgi</code>. And I created a python virtual environment within the project directory named <code>developer</code>.</p>
  
  <p>The allowed_hosts in the <code>settings.py</code> looks like this : </p>
  
  <pre><code>ALLOWED_HOSTS = ['xxx.xxx.xxx.xxx', 'localhost', '127.0.0.1']`
  </code></pre>
  
  <p>I added the static_url and the static_root:</p>
  
  <pre><code>STATIC_URL = '/static/'
  STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
  </code></pre>
  
  <p>I did run a <code>collectstatic</code></p>
  
  <p>And I configured <code>apache</code> by editing the <code>000-default.conf</code> :</p>
  
  <pre><code> &lt;VirtualHost *:80&gt;
      Alias /static /home/toto/Desktop/dash_test/static
      &lt;Directory /home/toto/Desktop/dash_test/static&gt;
          Require all granted
      &lt;/Directory&gt;
  
      &lt;Directory /home/toto/Desktop/dash_test/dash_test&gt;
          &lt;Files wsgi.py&gt;
              Require all granted
          &lt;/Files&gt;
      &lt;/Directory&gt;
  
      WSGIDaemonProcess dash_test python-home=/home/toto/Desktop/dash_test/developer python-path=/home/toto/Desktop/dash_test
      WSGIProcessGroup dash_test
      WSGIScriptAlias / /home/toto/Desktop/dash_test/dash_test/wsgi.py
   &lt;/VirtualHost&gt;
  </code></pre>
  
  <p>when I try to access the localhost I get this error:</p>
  
  <blockquote>
    <p>Internal Server Error
      The server encountered an internal error or misconfiguration and was unable to complete your request.
      Please contact the server administrator at [no address given] 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.
    Apache/2.4.18 (Ubuntu) Server at localhost Port 80</p>
  </blockquote>
  
  <p>Here is the content of the apache2 <code>error.log</code>:</p>
  
  <pre><code>[Thu Jun 14 13:25:48.134132 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] mod_wsgi (pid=21611): Target WSGI script '/home/toto/Desktop/dash_test/dash_test/wsgi.py' cannot be loaded as Python module.
  [Thu Jun 14 13:25:48.134152 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] mod_wsgi (pid=21611): Exception occurred processing WSGI script '/home/toto/Desktop/dash_test/dash_test/wsgi.py'.
  [Thu Jun 14 13:25:48.134167 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] Traceback (most recent call last):
  [Thu Jun 14 13:25:48.134182 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106]   File "/home/toto/Desktop/dash_test/dash_test/wsgi.py", line 11, in &lt;module&gt;
  [Thu Jun 14 13:25:48.134203 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106]     from django.core.wsgi import get_wsgi_application
  [Thu Jun 14 13:25:48.134216 2018] [wsgi:error] [pid 21611] [remote 127.0.0.1:15106] ImportError: No module named django.core.wsgi
  </code></pre>
  
  <p>I am using MySQL and phpMyAdmin instead of db.sqlite3</p>
  
  <p>Thanks a lot.</p>