User avatar
ibshar
Posts: 22
Joined: Sun Jul 31, 2016 3:00 pm

Flask app deployment issue on Apache 2.4

Wed Aug 16, 2017 11:43 am

Hi,

I have developed a Flask web app which I am now trying to host on Apache using the mod_wsgi documentation.

I created a appName.wsgi file in the /var/www/MyApp directory.
Then for configuring Apache I created a config file in the /etc/apache2/site-available/myApp.config with the below config

Code: Select all

<VirtualHost *>
    ServerName example.com

    WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5
    WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi

    <Directory /var/www/yourapplication>
        WSGIProcessGroup yourapplication
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>
</VirtualHost>
then after registering the new config and restarting apache, I am still not able to access my web page!
I tried the URL: http:localhost/example.com but keep getting 404 no page error!

Further when i removed the Virtual Host and servername and changed my config file in the /etc/apache2/site-available/myApp.config to below, it works, and my web app is available at http://localhost

Code: Select all

WSGIDaemonProcess yourapplication user=user1 group=group1 threads=5
    WSGIScriptAlias / /var/www/yourapplication/yourapplication.wsgi

    <Directory /var/www/yourapplication>
        WSGIProcessGroup yourapplication
        WSGIApplicationGroup %{GLOBAL}
        Require all granted
    </Directory>
Can some one please explain whats the problem with my configuration.

scotty101
Posts: 4245
Joined: Fri Jun 08, 2012 6:03 pm

Re: Flask app deployment issue on Apache 2.4

Wed Aug 16, 2017 12:14 pm

Have you created a wsgi file? What does it contain?

I'm guessing that the config you've posted is just an example rather than the real config that you expect to work.

Are you following the guidance posted on this page? http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
ibshar
Posts: 22
Joined: Sun Jul 31, 2016 3:00 pm

Re: Flask app deployment issue on Apache 2.4

Thu Aug 17, 2017 5:25 am

scotty101 wrote:
Wed Aug 16, 2017 12:14 pm
Have you created a wsgi file? What does it contain?

I'm guessing that the config you've posted is just an example rather than the real config that you expect to work.

Are you following the guidance posted on this page? http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/
Yes, I have created the WSGI file and I have done it according to the information in the flask page (http://flask.pocoo.org/docs/0.12/deploying/mod_wsgi/).

I did not post the actual config because my question is more on why the config does not work with VirtualHost tags while it works when i comment the Virtual host tags as posted above.

Return to “Networking and servers”