2

I have been trying to deploy my application on Ubuntu web server but with limited success. The virtual host file defined by me is :

    #WSGIRestrictStdout Off
    <VirtualHost *:80>
    ServerName demo.engineerinme.com
    WSGIDaemonProcess fedoracollege  user=engineer group=www-data threads=5
    WSGIScriptAlias / /home/engineer/fedora-college/fedora_college.wsgi
    <Directory /home/engineer/fedora-college/>
                    WSGIProcessGroup fedoracollege
                    WSGIApplicationGroup %{GLOBAL}
                    WSGIScriptReloading On
                    Options All ExecCGI Indexes FollowSymLinks
                    Order allow,deny
                    Allow from all

    </Directory>

    Alias /static /home/engineer/fedora-college/fedora_college/static
    <Directory /home/engineer/fedora-college/fedora_college/static/>
                    Order allow,deny
                    Allow from all
    </Directory>

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

The problem I am facing is that , the static content is working correctly but the flask application is not running. Like http://demo.engineerinme.com shows a not found error. But the http://demo.engineerinme.com/static works.

The wsgi script for the deployment is :

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/home/engineer/fedora-college/")

from fedora_college import app as application
application.secret_key = 'Add your secret key'

Error Log :

[Mon Jun 30 23:01:31 2014] [debug] mod_deflate.c(615): [client 59.177.114.30] Zlib: Compressed 233 to 180 : URL /
[Mon Jun 30 23:01:32 2014] [debug] mod_deflate.c(615): [client 59.177.114.30] Zlib: Compressed 233 to 180 : URL /
[Mon Jun 30 23:01:51 2014] [debug] mod_deflate.c(615): [client 59.177.114.30] Zlib: Compressed 233 to 180 : URL /

Access.log

        59.177.114.30 - - [30/Jun/2014:23:01:32 +0400] "GET / HTTP/1.1" 404 441 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"
        59.177.114.30 - - [30/Jun/2014:23:01:51 +0400] "GET / HTTP/1.1" 404 442 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36"

The code for the application is present here :https://github.com/hammadhaleem/fedora-college/

Any help with possible deployment would be highly appreciated.

Thanks

3
  • please include the apache error log too Commented Jun 30, 2014 at 12:23
  • @PaoloCasciello , i have added the output for the log files. Commented Jun 30, 2014 at 19:03
  • No, I don't think that's mandatory. Commented Jul 1, 2014 at 3:45

1 Answer 1

1

I faced this problem and the solution for the same was in the virtual host file.

Also sometimes the Apache logs showed this error:

[Mon Oct 17 15:24:24 2011] [error] [client 90.181.85.69] (13)Permission denied: mod_wsgi (pid=21805): Unable to connect to WSGI daemon process 'fedoracollege' on '/var/run/apache2/wsgi.16282.4.1.sock' after multiple attempts.

This problem has been explained here properly. I just rebuilt the wsgi_mod.

https://serverfault.com/questions/322131/wsgi-says-permissions-denied-on-my-ubuntu-server-no-wsgisocketprefix-setting

Also, rewriting the virtual host file to this format. (Removing virtualhost and direcory tags)

Alias /static  /home/engineer/fedora-college/fedora_college/static
WSGIDaemonProcess fedoracollege user=engineer group=www-data threads=5
#WSGIDaemonProcess fedoracollege maximum-requests=1000 display-name=fedora-college processes=4 threads=4
WSGISocketPrefix /var/run/wsgi
WSGIRestrictStdout Off
WSGIRestrictSignal Off
WSGIPythonOptimize 1
WSGIScriptAlias /  /home/engineer/fedora-college/fedora_college.wsgi
<Location />
    WSGIProcessGroup fedoracollege
</Location>


ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel debug
CustomLog ${APACHE_LOG_DIR}/access.log combined

Also, set the

application = True 

For proper error reporting.

Hope this helps someone. (Don't forget to upvote :P )

Thanks for all your help.

Sign up to request clarification or add additional context in comments.

2 Comments

You don't need WSGIRestrictStdout or WSGIRestrictSignal for a very long long time. WSGIPythonOptimize doesn't really buy you anything either. And you probably mean something other than 'application = True '.
Odd, cause I don't see any edits to the page related to what I highlighted.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.