Comments on How to run Python Scripts with Apache and mod_wsgi on Ubuntu 18.04
mod_wsgi is an Apache module that can be used for serving Python scripts over HTTP via Apache web server like Django, Web.py, Werkzug, Chery.py, TurboGears, and Flask. In this tutorial, we will learn how to install and set up of mod_wsgi with the Apache server on Ubuntu 18.04 LTS (Bionic Beaver) server.
11 Comment(s)
Comments
replace: WSGIScriptAlias /wsgi /var/www/html/wsgi.py
with
WSGIScriptAlias /wsgi /var/www/html/wsgy.py
If wsgi configuration file name is "wsgi.conf", shouldn't "sudo a2enconf mod-wsgi" be "sudo a2enconf wsgi"?
Yes, it should be wsgi and not mod-wsgi. I've updated the tutorial.
sudo a2enconf wsgi --> a2enmod
I initialy failed with this, receiving a 'TypeError: sequence of byte string values expected, value of type str found' in the error log
expressing the string as bytes, prefixing the string with html = b'the output' works but needs every line as the next error was
SyntaxError: cannot mix bytes and nonbytes literals
typecasting the whole output to bytes before output worked beautifly though
html = bytes(html, encoding= 'utf-8')
Thanks for a nice cleare turorial
I was using python3 and ibapache2-mod-wsgi-py3 so I initialy failed with this, receiving a
TypeError: sequence of byte string values expected, value of type str found' in the error log
expressing the string as bytes, prefixing the string with html = b'the output' works but needs every line as the next error was
SyntaxError: cannot mix bytes and nonbytes literals
typecasting the whole output to bytes before output worked beautifly though
html = bytes(html, encoding= 'utf-8')
Thanks for a nice clear turorial
didnt work for me error:
Internal Server Errorwhy its like that?
Take a look into the error.log file, there you should be able to find out why.
Thanks,
works perfect with Ubuntu 18
Hey Im a total noob here, So im following the tutorial you showed here and when i do nano /var/www/html/wsgy.py it opens the file and then when i write something in it and close it, it shows that the file isnt writeable. Ive given it permissions as well but its not working.. any suggestion would be really helpful
I also get an Internal Server Error.
My apache error log shows nothing.
My apache access log shows nothing.
I have banged my head against the wall and am unable to get this to work.
In addition to your site (which neglects to mention the need to run a2enmod wsgi) I also tried to follow, verbatim, the steps in:
https://www.youtube.com/watch?v=q__Nn0RRBvE
Nothing works. At one point, instead of "Internal Server Error" I got a different error:
Not Found -- The requested URL was not found on this server
Yet, again, no output to my apache error log or access log files which are located on my Ubuntu 18 server at:
/var/log/apache2/error.log
/var/log/apache2/access.log
Any ideas?
Dennis Allard