title: How to deploy flask app on AWS EC2 - Internal Server Error?
body: <p>I would like to deploy flask app on AWS EC2. But I have encountered <strong>500 Internal Server Error</strong>.</p>
  
  <p>First, I have installed apache webserver and mod_wsgi.</p>
  
  <pre><code>$ sudo apt-get update
  $ sudo apt-get install apache2
  $ sudo apt-get install libapache2-mod-wsgi
  $ sudo apt-get install libapache2-mod-wsgi-py2
  </code></pre>
  
  <p>I've installed pip3 and flask.</p>
  
  <pre><code>$ sudo apt-get install python3-pip
  $ sudo pip3 install flask
  </code></pre>
  
  <p>This is the flask.wsgi file in the flaskapp directory.</p>
  
  <pre><code>import sys
  sys.path.insert(0, '/var/www/html/flaskapp')
  
  from flaskapp  import app as application
  </code></pre>
  
  <p>I've make the mod_wsgi enable.</p>
  
  <pre><code>WSGIDaemonProcess flaskapp threads=5
  WSGIScriptAlias / /var/www/html/flaskapp/flaskapp.wsgi
  
  &lt;Directory flaskapp&gt;
      WSGIProcessGroup flaskapp
      WSGIApplicationGroup %{GLOBAL}
      Order deny,allow
      Allow from all
  &lt;/Directory&gt;
  </code></pre>
  
  <p>Finally, I have restarted apache2.</p>
  
  <pre><code>$ sudo apachectl restart
  </code></pre>
  
  <p>When I go to AWS EC2 domain, I got an <strong>500 Internal Server Error</strong>.</p>
  
  <pre><code>The server encountered an internal error or misconfiguration and was unable to complete your request.
  
  Please contact the server administrator at webmaster@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.
  </code></pre>
  
  <p>My flaskapp should run on python3.</p>
  
  <p>I don't know how to handle this issue.</p>