0

I am trying to deploy a FLASK application in Ubuntu VPS using wsgi but I get an Internal server error. Checking the apache.log gives me following error:

No such file or directory: 'files/filesystem/filesystem.pickle'.

My directory tree looks like this under /var/www/:

dmft_seacrh_engine
    files
        filesystem
            filesystem.pickle
    dmft_search.wsgi
    dmft_search
        controllers
            search.py

I am trying to open the filesystem.pickle inside search.py as following:

with open('/files/filesystem/filesystem.pickle', 'rb') as handle:
    filesystem = pickle.load(handle)

Contents of the dmft.wsgi file are:

activate_this = '/opt/dmft/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/dmft_search_engine")

from dmft_search import app as application

This is how my conf file looks:

<VirtualHost *:80>
                ServerName      dmft_search_engine.com
                WSGIScriptAlias / /var/www/dmft_search_engine/dmft_search.wsgi
                <Directory /var/www/dmft_search_engine/dmft_search/>
                        Order allow,deny
                        Allow from all
                </Directory>
                Alias /static /var/www/dmft_search_engine/dmft_search/static
                <Directory /var/www/dmft_search_engine/dmft_search/static/>
                        Order allow,deny
                        Allow from all
                </Directory>
                Alias /files /var/www/dmft_search_engine/files/$
                <Directory /var/www/dmft_search_engine/files/>$
                        Order allow,deny
                        Allow from all
                </Directory>

                ErrorLog ${APACHE_LOG_DIR}/error.log
                LogLevel warn
                CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Kindly help me out. I have also added an alias for /files in .conf file. How can I resolve this?

Raghav Pandya
  • 33
  • 1
  • 3

1 Answers1

0

The problem is that the app run in the context of root directory so the correct path should be:

with  open('var/www/html/dmft_search_engine/files/filesystem/filesystem.pickle', 'rb') as handle:
        filesystem = pickle.load(handle)
Raghav Pandya
  • 33
  • 1
  • 3