Comments on How to run Python Scripts with Apache and mod_wsgi on Ubuntu 20.04

mod_wsgi is an Apache module that provides an interface for hosting Python based web applications under Apache. In this tutorial, we will learn how to install and set up of mod_wsgi with the Apache server on Ubuntu 20.04 server.

6 Comment(s)

Add comment

Please register in our forum first to comment.

Comments

By: Laksha

Does tis work for Debian 10 ?

By: Jose Laurentino III

Thanks a lot Hitesh,

It worked as expected!

My setup: Ubuntu 20.04 LTS

By: Martin Cendejas

Thanks a lot Hitesh, a good guide.

Just, I suggest addition 2 steps:

1.- After change ownership to wsgy.py, I changed file permission to 775 too

   $ sudo chmod -R 775 /var/www/html/wsgy.py

2.- After enable mod-wsgi configuration, I created a simlink of wsgi.conf to conf-enabled directory:

   $ sudo ln -s /etc/apache2/conf-available/wsgi.conf /etc/apache2/conf-enabled/wsgi.conf

Then, I restarted apache and voula, running perfect.

By: till

The symlink you added manually gets added by the command "a2enconf wsgi", you might have missed executing this command from the tutorial.

By: srinivasan

hi how to do this with my own flask application

i really strugling this would be really helpful!

By: Coding teacher

Hello,

During the setup I was facing a little issue: Apache Server threw an error because of the type of response returned by the application function.

Here is the trace:

TypeError: sequence of byte string values expected, value of type str found

So I had to change the return statement by adding encode("utf-8") to the html variable.

- return [html]+ return [html.encode('utf-8')]