Why apache throws Target WSGI script not found or unable to stat on Flask app?
Question: I want to setup my flask app for apache on my ubuntu server using wsgi. But
after my setup, I get the following browser error:

    
    
    Not Found
    The requested URL / was not found on this server.
    

The apache error log throws:

    
    
    Target WSGI script not found or unable to stat: 
        /var/www/html/appname/appname.wsgi
    

My wsgi file looks like this:

    
    
    #!/usr/bin/python
    import sys
    import logging
    logging.basicConfig(stream=sys.stderr)
    sys.path.insert(0,"/var/www/html/appname/")
    
    from IdeaHound import app as application
    application.secret_key = 'here_the_key'
    

and my apache config file looks like this:

    
    
    <VirtualHost *:80>
                    ServerName server_ip_here
                    WSGIScriptAlias / /var/www/html/appname/appname.wsgi
                    <Directory /var/www/html/appname/>
                            Order allow,deny
                            Allow from all
                    </Directory>
                    ErrorLog ${APACHE_LOG_DIR}/error.log
                    LogLevel info
                    CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

The **appname** folder has the following structure: appname

    
    
    --application.py
    --appname.wsgi
    --LICENSE
    --README.md
    --requirements.txt
    --db_manage.py
    --appname
    ----frontend
    ----__inity__.py
    ----__init__.pyc
    ----models
    ----__pycache__
    ----socket_interface
    --AppName
    ----__init__.py
    ----static
    ----templates
    --instance
    ----config.py
    

What am I missing here to make the webserver run correctly with Flask?


Answer: Please read the following link of Digital Ocean. Do as describe in it. And
your app will be up and running in just 5 mins.

<https://www.digitalocean.com/community/tutorials/how-to-deploy-a-flask-
application-on-an-ubuntu-vps>

Also do check the apache error logs for more information if it still throws an
error.

    
    
    /var/log/apache2/error.log
    

