[Flask] Deploying as a Windows service

Corey Boyle coreybrett at gmail.com
Sun Aug 5 23:05:14 EDT 2018


is Apache using a different config file when running as a service?

could also be a file system permission issue?

what account is the service running under?


__
Corey

On Sun, Aug 5, 2018, 10:31 PM CCP Dragonedge <ccp at drsb.com.my> wrote:

> Sorry, it should be mod_wsgi 4.6.4, not 4.5.4
> p
>
> On 6 August 2018 at 10:27, CCP Dragonedge <ccp at drsb.com.my> wrote:
>
>> Hi Unai,
>>
>> Thanks for taking the time.
>>
>> With regards to (1), I didn't see anything more meaningful. Inside my
>> myapp.py, I do a "from module wfADM import wfUser". It just says it
>> couldn't find module wfADM.
>>
>> As for (2), before I installed mod_wsgi, I did test it out as a Windows
>> service on a simple html file - no problems.
>>
>> This is the entire scenario (sorry in advance for this long post):
>>
>> Initially, I had Python 2.7, Flask, and MySQL 8 running on a Windows 7
>> box. This wasn't my development machine, it was going to be production, but
>> I just wanted to make sure that everything worked, as I had never worked
>> with Apache before. Then, I installed Apache 2.4 - pleasantly surprised
>> that it was really easy. No problem as a Windows service, either (i.e.
>> httpd -k install, then going into Services and starting it up).
>>
>> So, apart from Apache, my production and development machines were
>> basically identical. Therefore, I tried to install mod_wsgi on my
>> DEVELOPMENT machine - and ran into all sorts of pain. After a very helpful
>> exchange with the mod_wsgi boss, Graham Dumpleton, on Github (#347), my
>> conclusion was that I had to use Python 3.6. After doing that (the only
>> real change I had to make was changing MySQLdb to pymsql), I then managed
>> to install mod_wsgi 4.5.4 (after much effort - I finally realized I had to
>> install the latest Visual C++ compilers from Microsoft). Then, everything
>> worked fine (now that I think of it, I didn't try to set up Apache as a
>> Windows service on my development machine - I'll give that a shot when I
>> have a bit more time).
>>
>> Regardless, I basically did this on my PRODUCTION environment based on my
>> experience on my development box:
>>
>> 0) Apache24 and MySQL 8 already installed, so I just left them
>> 1) Uninstalled Python 2.7, which also gets rid of Flask
>> 2) Installed Python 3.6
>> 3) Installed Flask
>>    - tested my application on the Flask server; worked without any
>> problems
>> 4) Installed mod_wsgi
>>    - had to install the Visual C++ compilers, but after that, no issues
>> 5) Set up the virtual host and the wsgi file, which leads to....
>>
>> Current situation:
>> When I manually start up Apache by just typing httpd.exe on the command
>> line, no problems accessing my Flask app from Apache. But when I try to set
>> up Apache as a Windows service (httpd -k install, and then going to
>> Services), I get the problem above (unable to see my modules).
>>
>> Thanks for taking the time to read this!
>> p
>>
>> On 6 August 2018 at 02:10, Unai Rodriguez <unai at sysbible.org> wrote:
>>
>>> Hi,
>>>
>>> (1) Is there any more specific error on Apache error logs?
>>>
>>> (2) I’d make sure first Apache starts properly as a service. Can you
>>> test something else (perhaps a simple html page)  to make the Apache
>>> service is configured properly?
>>>
>>> (3) If getting (1) and (2) did not help enough for you to figure it out,
>>> please submit exact steps on how yo configured Apache to start as a service
>>> and the Apache configuration for your Flask app
>>>
>>> Thanks,
>>> Unai Rodriguez
>>> On 5 Aug 2018, 14:31 +0200, CCP Dragonedge <ccp at drsb.com.my>, wrote:
>>>
>>> Hi,
>>>
>>> I am deploying my Flask application on Apache24 using mod_wsgi 4.5.4
>>> running on a Windows 7 machine. I have encountered something strange - when
>>> I start and stop Apache manually (i.e. by typing httpd.exe from the command
>>> line to start, and just hitting ctrl-C to stop), everything works fine.
>>>
>>> When I, however, install Apache as a Windows service (by doing a "httpd
>>> -k install"; so it starts up when the machine is booted), I get a "500
>>> internal server error" when I try to access my Flask application.
>>>
>>> According to the error logs, Flask can't see my modules. I know it's
>>> something to do with Apache because when I just run the Flask server
>>> ("python myapp.py"), I have no problems.
>>>
>>> Anyone experience this? If so, how did you overcome this? And I hope
>>> this isn't off-topic - if it is, sorry and please point me to the right
>>> place.
>>>
>>> Thanks,
>>> p
>>> _______________________________________________
>>> Flask mailing list
>>> Flask at python.org
>>> https://mail.python.org/mailman/listinfo/flask
>>>
>>>
>>
>
> _______________________________________________
> Flask mailing list
> Flask at python.org
> https://mail.python.org/mailman/listinfo/flask
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20180805/eb908206/attachment.html>


More information about the Flask mailing list