title: Is it possible to have flask api running on apache with already running PHP site for same domain?
body: <p>Is is possible to run flask rest api in apache + ubuntu server where already PHP website is running with that domain??</p>
  <p>in short: if I browse url <a href="http://www.example.com" rel="nofollow noreferrer">www.example.com</a> then normal php website should load. if I call <a href="http://www.example.com/services/api" rel="nofollow noreferrer">www.example.com/services/api</a> then flask api should give result....</p>
  <p><strong>Updated =&gt; Answer</strong>
  Finally I found a solution, posting here if it can help someone...
  (Ubuntu Server)</p>
  <p>--&gt;with root (Assuming Python and Pip already installed)</p>
  <ol>
  <li><code>sudo apt-get install libapache2-mod-wsgi-py3 python3-dev</code></li>
  <li><code>sudo apt-get install python3-pip</code></li>
  <li><code>pip3 install virtualenv</code></li>
  </ol>
  <p>--&gt;with domain user
  navigate to folder where you want to create virtual environment... then type below command (you can change virtual environment name according to your need)</p>
  <ol>
  <li><code>python3 -m virtualenv myenv</code> &lt;-(any name)</li>
  <li>activate environment with command <code>source myenv/bin/activate</code></li>
  <li>install flask with commend <code>pip install flask</code></li>
  <li>create file  below data--&gt; <code>flaskapp.wsgi</code> in project folder or anywhere you want... then following code</li>
  </ol>
  <pre><code>import logging
   import sys
  
  activate_this = '/your/envfolder/path/bin/activate_this.py'
  
  exec(compile(open(activate_this).read(), activate_this, 'exec'), dict(__file__=activate_this))
  
  logging.basicConfig(stream=sys.stderr)
  sys.path.insert(0, '/your/app/folder/path/where/you/can/import/app')
  from App import app as application
  #application.secret_key = 'anything-you-wish'
  </code></pre>
  <p>Finally with  <code>etc/apache2/sites_available</code> and your <code>sitename.conf</code> add below code...</p>
  <pre><code>WSGIScriptAlias /your/wsgi/folderpath/flaskapp.wsgi
      &lt;Directory /your/wsgi/folderpath/&gt;
          # set permissions as per apache2.conf file
          allow from all
          Options FollowSymLinks
          AllowOverride None
          Require all granted
      &lt;/Directory&gt;
  </code></pre>
  <p><strong>Note:</strong> <em>This is how I made it to work... I am not a professional server developer, I am not sure if this is a right way to do it...</em></p>