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:

http://flask.pocoo.org/ <http://flask.pocoo.org/>

https://pypi.org/project/mod-wsgi/ <https://pypi.org/project/mod-wsgi/>

https://www.youtube.com/watch?v=H6Q3l11fjU0 
<https://www.youtube.com/watch?v=H6Q3l11fjU0>

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

> On 9 Jul 2019, at 3:33 pm, prasad mokkapati <[email protected]> wrote:
> 
> 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")
> 
> 
> 
> 
> -- 
> 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 [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/modwsgi 
> <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
>  
> <https://groups.google.com/d/msgid/modwsgi/8af36f3e-65f7-4739-a5ce-90d450a4e4d0%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/13DD7F87-D1A3-480B-8D72-980ECC9FA96C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to