Docker debian and Apache

11 views
Skip to first unread message

prasad mokkapati

unread,
Jul 9, 2019, 1:34:30 AM7/9/19
to modwsgi
I am running Docker and would like to run Python from Apache using mod_wsgi. My Dockerfile looks as follows

FROM debian:latest


RUN apt-get update && apt-get install -y --no-install-recommends apt-utils

RUN apt-get install -y apache2

RUN apt-get install -y libapache2-mod-wsgi

RUN apt-get install -y python-dev



COPY test.py /var/www/html/

RUN chmod 755 /var/www/html/test.py


# Configure apache

RUN echo '. /etc/apache2/envvars' > /root/run_apache.sh

RUN echo 'mkdir -p /var/run/apache2' >> /root/run_apache.sh

RUN echo 'mkdir -p /var/lock/apache2' >> /root/run_apache.sh

RUN echo '/usr/sbin/apache2 -D FOREGROUND' >> /root/run_apache.sh

RUN chmod 755 /root/run_apache.sh


EXPOSE 80

CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]



When I run it, the text in test.py shows up, but it's not running python. Is there a way to have mod_wsgi load so test.py runs as python instead of the script being printed

When I use the URL where the file is, I see that the code is run as html and not calling python.

#!/usr/bin/env python

print("Content-type: text/html\n")
print("This is python on Apache2")



Graham Dumpleton

unread,
Jul 9, 2019, 1:39:00 AM7/9/19
to mod...@googlegroups.com
For a start, that is not a WSGI application. It is a CGI script. To run CGI scripts you don't need mod_wsgi.

If you are new to Python web applications, I would suggest starting out with a Python WSGI framework like Flask and learn what constitutes a Python WSGI application.

When you work that out, rather than try and configure Apache yourself, use mod_wsgi-express it you really want to use Apache to host Python web applications in a container using docker.

See:




The last video talks about running mod_wsgi-express in containers.

-- 
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
To view this discussion on the web visit https://groups.google.com/d/msgid/modwsgi/8af36f3e-65f7-4739-a5ce-90d450a4e4d0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages