Installa of mod_WSGI

65 views
Skip to first unread message

Gaetano Leoni

unread,
Oct 27, 2024, 3:50:41 PM10/27/24
to modwsgi
Hi, has anyone ever installed mod_wsgi with apache ?
I read How to use Django with Apache and mod_wsgi and after installing mod_wsgi and updating http.conf apache doesn't start because mod_WSGI.so file is missing and also mod_wsgi folder is not present inside apache folder

Graham Dumpleton

unread,
Oct 27, 2024, 3:53:09 PM10/27/24
to mod...@googlegroups.com
What steps did you take to install mod_wsgi?

Which of the following did you do?

* Install system Apache/mod_wsgi package.
* Install using pip install mod_wsgi and configure Apache to use that.
* Build and install mod_wsgi from source code.
* Some other way.

What changes did you make to the Apache configuration?

On 28 Oct 2024, at 3:49 AM, Gaetano Leoni <gaetan...@gmail.com> wrote:

Hi, has anyone ever installed mod_wsgi with apache ?
I read How to use Django with Apache and mod_wsgi and after installing mod_wsgi and updating http.conf apache doesn't start because mod_WSGI.so file is missing and also mod_wsgi folder is not present inside apache folder

--
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 view this discussion visit https://groups.google.com/d/msgid/modwsgi/61ea575a-dbb6-42ce-bfa0-f2c6a2cef30fn%40googlegroups.com.

Gaetano Leoni

unread,
Oct 31, 2024, 5:30:07 AM10/31/24
to mod...@googlegroups.com
Which of the following did you do?
I followed the directions in this linkhttps://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/modwsgi/


* Install system Apache/mod_wsgi package.
I only installed xammp


* Install using pip install mod_wsgi and configure Apache to use that.
From https://pypi.org/ I downloaded mod_wsgi and installed using pip install mod_wsgi
WSGIScriptAlias / /xampp/htdocs/PalestraGes/PalestraGes/wsgi.py
WSGIPythonHome /xampp/htdocs/PalestraGes/venv
WSGIPythonPath /xampp/htdocs/PalestraGes.

<Directory /xampp/htdocs/PalestraGes/PalestraGes>.
<Files wsgi.py>
Require all granted
</Files>
</Directory>


* Build and install mod_wsgi from source code.
I read that you have to compile a file. I downloaded the mod_wsgi-5.0.1.tar.gz folder and in the src/server folder there are several files but I don't know which one I should use or how to compile it (I think it's refereed to the mod_wsgi.so file ?)

* Some other way.
In the notes I read that in the apache folder there should be the mod_WSGI folder but it is not present


Graham Dumpleton

unread,
Oct 31, 2024, 5:50:52 AM10/31/24
to mod...@googlegroups.com
If you are installing on Windows using "pip install" method, after you do that you need to run:

    mod_wsgi-express module-config

This will output some lines like:

    LoadModule wsgi_module /usr/local/lib/python2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so
    WSGIPythonHome /usr/local/lib

That example is for Linux though.

On Windows the suffix on the loadable Apache module referenced by LoadModule will be .pyo or .pyd from memory, it will not be a .so extension.

That you say you are getting error about mod_wsgi.so file being missing means that you probably didn't do that and have copied too literally the Django documentation or something else which says to use a .so extension.

So verify what you used for LoadModule directive and ensure it matches what that command outputs.

Gaetano Leoni

unread,
Oct 31, 2024, 6:56:06 AM10/31/24
to mod...@googlegroups.com
Thanks for the advice, I ran the command and below is the result
(GymGes) PS C:\xampp\htdocs\PalestraGes> mod_wsgi-express module-config
LoadFile “C:/Users/Gaetano/AppData/Local/Programs/Python/Python313/python313.dll”
LoadModule wsgi_module “C:/xampp/htdocs/PalestraGes/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp313-win_amd64.pyd”
WSGIPythonHome “C:/xampp/htdocs/PalestraGes/PalestraGes”

I edited the http.conf file by adding the line load
LoadModule wsgi_module modules/mod_wsgi.so

WSGIScriptAlias / /xampp/htdocs/PalestraGes/PalestraGes/wsgi.py
WSGIPythonHome /xampp/htdocs/PalestraGes/venv
WSGIPythonPath /xampp/htdocs/PalestraGes

<Directory /xampp/htdocs/PalestraGes/PalestraGes>.
<File wsgi.py>
Requires all permissions
<File>
<Directory>

I ran the command to check but it returns this error
C:\xampp\apache\bin>httpd -t
AH00526: Syntax error on line 576 of C:/xampp/apache/conf/httpd.conf:
Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included in the server configuration.

Is the load line correct?
If yes, how do I compile the

Gaetano Leoni

unread,
Oct 31, 2024, 1:36:29 PM10/31/24
to mod...@googlegroups.com
Hi I managed to fix the httpd.conf file and now when I launch http -d it doesn't return any error.
I launched xampp and invoked the webserver with 192.3168.x.xx but it fails to connect, what can I do to figure out where the error is ?
I have checked all the files present in the logs folder and no errors appear

Graham Dumpleton

unread,
Oct 31, 2024, 7:23:52 PM10/31/24
to mod...@googlegroups.com
Is the Apache web server hosted on your own local machine. If it is try http://localhost instead if it is listening on standard port 80.

Trying to use actual IP of your local machine may well fail on Windows depending on how the firewall is configured.

Also, it may not work depending on whether Apache configuration was done correctly. All too common for people to get confused around how to set up VirtualHost definitions in Apache configuration. Since you don't say where you added WSGIScriptAlias directive and what VirtualHost definitions you have, is hard to say whether that may be the issue.

Graham

Message has been deleted

Gaetano Leoni

unread,
Nov 1, 2024, 12:38:06 PM11/1/24
to modwsgi
I installed xampp on a windows machine locally. The httpd.conf file I updated it by changing port 80 to 8000 (I don't know if this is right) and at the bottom of the file I added these lines
GymGes/venv/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp313-win_amd64.pyd”

WSGIScriptAlias / / /xampp/htdocs/PalestraGes/PalestraGes/wsgi.py
WSGIPythonHome /xampp/htdocs/PalestraGes/PalestraGes

WSGIPythonPath /xampp/htdocs/PalestraGes.

<Directory /xampp/htdocs/PalestraGes/PalestraGes>.
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Then I created the httpd-vhosts.conf file which contains these lines
<VirtualHost *:8000>
    ServerName 192.168.1.54
WSGIScriptAlias / /xampp/htdocs/PalestraGes/PalestraGes/wsgi.py
WSGIPythonHome /xampp/htdocs/PalestraGes/PalestraGes

WSGIPythonPath /xampp/htdocs/PalestraGes.

<Directory /xampp/htdocs/PalestraGes/PalestraGes>.
<Files wsgi.py>
Require all granted
</Files>
</Directory>

I run this command httpd -t and it comes back ok

I updated the settings.py file with this line
ALLOWED_HOSTS = [“localhost”, “127.0.0.1”, “192.168.x.x:8000”]
and whether I use 192.168.x.x:8000 or localhost it loads the xampp base page 192.168.1.54:8000/dashboard

I don't know if I did something wrong or if there is some other thing to do

Gaetano Leoni

unread,
Nov 1, 2024, 12:41:29 PM11/1/24
to modwsgi


Gaetano Leoni

17:38 (0 minuti fa)




a modwsgi
I installed xampp on a windows machine locally. The httpd.conf file I updated it by changing port 80 to 8000 (I don't know if this is right) and at the bottom of the file I added these lines
GymGes/venv/Lib/site-packages/mod_wsgi/server/mod_wsgi.cp313-win_amd64.pyd”

WSGIScriptAlias / / /xampp/htdocs/PalestraGes/PalestraGes/wsgi.py
WSGIPythonHome /xampp/htdocs/PalestraGes/PalestraGes
WSGIPythonPath /xampp/htdocs/PalestraGes.

<Directory /xampp/htdocs/PalestraGes/PalestraGes>.
<Files wsgi.py>
Require all granted
</Files>
</Directory>

Then I created the httpd-vhosts.conf file which contains these lines
<VirtualHost *:8000>
    ServerName 192.168.1.54
WSGIScriptAlias / /xampp/htdocs/PalestraGes/PalestraGes/wsgi.py
WSGIPythonHome /xampp/htdocs/PalestraGes/PalestraGes
WSGIPythonPath /xampp/htdocs/PalestraGes.

<Directory /xampp/htdocs/PalestraGes/PalestraGes>.
<Files wsgi.py>
Require all granted
</Files>
</Directory>

I run this command httpd -t and it comes back ok

I updated the settings.py file with this line
ALLOWED_HOSTS = [“localhost”, “127.0.0.1”, “192.168.x.x:8000”]
and whether I use 192.168.x.x:8000 or localhost it loads the xampp base page 192.168.x.x:8000/dashboard


I don't know if I did something wrong or if there is some other thing to do


--
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+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/modwsgi/6049aafa-4fba-45ba-b994-2183e778c062n%40googlegroups.com.






Il giorno venerdì 1 novembre 2024 alle 00:23:52 UTC+1 Graham Dumpleton ha scritto:

Graham Dumpleton

unread,
Nov 1, 2024, 8:40:14 PM11/1/24
to mod...@googlegroups.com
You have fallen into one of the common mistakes people make using VirtualHost. The ServerName directive inside of a VirtualHost cannot be an IP address. It must be the fully qualified host name you use to access the site.

The only exception to this is that the very first VirtualHost encountered in the Apache configuration file will be used as a fallback. That is, if in addition to the VirtualHost you showed, if there was the default VirtualHost before that, then trying to access to the IP address will use that default VirtualHost instead.

Not knowing whether you have a default VirtualHost or not, then a quick change you can make is to use:

    <VirtualHost *:8000>
        ServerName 192.168.1.54.nip.io

instead. Then attempt to access you site using:


The "nip.io" is a special suffix which invokes a special DNS service which will cause that hostname to be mapped to the IP 192.168.1.54 and thus your machine.

If that access doesn't work, then there may be a networking issue.

So try that next.

Graham


Gaetano Leoni

unread,
Nov 2, 2024, 3:25:24 PM11/2/24
to modwsgi
Now it works, I have to find a way to start xampp as administrator by loading apache and mysql automatically, so just go to the browser and try it
Thanks for your patience
Reply all
Reply to author
Forward
0 new messages