python, trac, apache, mod_wsgi on windows - python

I'm using trac 1.2 on windows. Their documentation says it requires python2, so I pip install'd it with python2 x64, and spent a lot of time configuring some trac environments. Now I want to run trac through apache httpd so I can set it up with microsoft active directory, so I figured, okay, let's try mod_wsgi. I read this mod_wsgi documentation which mentions that python2 is built with VC9, and that apache, mod_wsgi, python binaries need to be consistent architecture throughout. So that means, for me, VC9, x64 for all. I installed the VC9 runtime from here. For mod_wsgi, I pip installd it using the mod_wsgi‑4.6.4+ap24vc9‑cp27‑cp27m‑win_amd64.whl file from here to avoid having to install VS2008's entire toolchain. Now I guess I need apache x64 VC9. The apache binary closest to VC9 I could find was VC10 here which says it loads VC9 modules, so I went ahead and tried it. I ran mod_wsgi-express module-config which gave me
LoadModule wsgi_module "c:/python27/lib/site-packages/mod_wsgi/server/mod_wsgiNone"
WSGIPythonHome "c:/python27"
The first line wasn't right, since httpd complained it couldn't load the module, so I changed it to
LoadModule wsgi_module "c:/python27/lib/site-packages/mod_wsgi/server/mod_wsgi.pyd"
I verified that that module exists at the specified path, and ran httpd which still error'd out with
httpd: Syntax error on line 179 of C:/Apache24/conf/httpd.conf: Cannot load c:/python27/lib/site-packages/mod_wsgi/server/mod_wsgi.pyd into server: The specified module could not be found.
So I guess the VC10 x64 apache binary I downloaded isn't backwards compatible with VC9 x64 mod_wsgi.
Does this mean I now need to build my own VC9 x64 apache binary? There must be a simpler way to achieve running trac 1.2 within an apache web server, right? Unfortunately, it's not as obvious to me. Any help is appreciated. Also, let me know if I need to clarify any other detail.

Related

Apache2 on Ubuntu gives Py_Initialize ImportError: No module named encodings

I'm working on Ubuntu with Apache2, Python 3.6.1. I followed the directions here to set it up with Django and mod_wsgi: How To Serve Django Applications with Apache and mod_wsgi on Ubuntu 14.04
I've looked at a lot of similar questions and still can't get it to work. The Apache error log spews the "ImportError: No module named 'encodings' almost constantly.
Here are the relevant settings in my Apache2 files:
In 000-default.conf:
WSGIDaemonProcess myproject python-home=/home/user/myproject/myprojectenv/ python-path=/home/user/myproject/myprojectenv/bin/python
WSGIProcessGroup myproject
WSGIScriptAlias / /home/user/myproject/myprojectenv/myproject/myproject/wsgi.py
In apache2.conf:
WSGIPythonPath /home/user/myproject/myprojectenv
Note that, when I check sys.prefix it equals what I have in the WSGIPythonPath above.
Yes, I've activated the virtual environment.
For my environment variables, I have:
PATH = /home/user/myproject/myprojectenv/bin:$PATH
PYTHONPATH = /home/user/myproject/myprojectenv/bin:$PYTHONPATH
PYTHONHOME = not set
I've tried various combinations of the environment variables being set and not being set. None that I've tried have worked.
When I followed the steps from the link above, I'm not sure that a new mod_wsgi was built that is for Python 3.6.1. I had tried (on another copy of my VM) to explicitly build a Python shared library and to build mod_wsgi with that. It failed miserably. I hesitate to go that route again unless I'm sure that's what I need to do.
Any help is greatly appreciated.
I did get passed this error. As #Alasdair pointed out, I did need to build Python with a shared library and then build mod_wsgi with that version of Python. I followed the directions here: Compiling mod_wsgi for a custom Python Build
The only difference is that I needed to add 'sudo' before 'make install' so the permissions were good for putting the module in the /usr/bin/apache2/modules directory.
I also needed to be sure LD_LIBRARY_PATH recognized the python library (I received a "error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory" error). That error was cleaned up by using 'ldconfig'.
I'm still having an Apache issue, which I will write up separately, but this got me passed the 'encodings' problem.

httpd and mod_wsgi ran with wrong python version

I am deploying a Django project with httpd on RHEL7. And changed the system default python version to python 3.4. But after I restarted the httpd, it still used python 2.7.
I searched a lot and it is mostly because mod_wsgi was built under the wrong python version. However, I checked that mod_wsgi was installed under python 3.4.
May I know how to make it run under the correct python version? Not too sure if httpd has a default python version. Thanks very much for your help!
Error Stack trace: No module named embed
I just find that it was due to the fact that I didn't Load 'wsgi_module' to the httpd conf file. I just followed the instruction https://github.com/GrahamDumpleton/mod_wsgi to add LoadModule into httpd.conf file. It solves my problem and now runs in the correct python version!
LoadModule wsgi_module "/usr/lib64/python3.4/site-packages/mod_wsgi/server/mod_wsgi-py34.cpython-34m.so"
WSGIPythonHome "/usr"
But I think it is strange that it will show module wsgi_module is already loaded,skipping. If I comment these lines, it will again run in python2.7

Which mod_wsgi Binary to download?

1) I am trying to setup a WAMPServer and am stuck on which file I need to download from the site: http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
I am using: Windows 7(64 bit), Apache 2.4.9 and Python 2.7.
2) Also, many of the tutorials I have seen on the matter say to download a .so file. However the above link contains .whl files?
I've been using this https://stackoverflow.com/a/20128269/2268507 as a guide.
I would really appreciate it if someone could shed some light on these two matters.
Thank you for your help.
That page on the gohike site tells you to go read:
https://github.com/GrahamDumpleton/mod_wsgi/blob/master/win32/README.rst
Did you do that?
That page for mod_wsgi explains what version you should use for what. It does this in reference to the binaries that the mod_wsgi downloads list has, but if you understand what Python wheels are then you can use those from the gohike site as well.
UPDATE
Note that details at this URL are obsolete. You should use pip install as described at:
https://pypi.python.org/pypi/mod_wsgi
Once installed, run mod_wsgi-express module-config to display config you should add to your Apache configuration file to load mod_wsgi that you installed using pip install.
Yes, read the Graham's [Git] and take a look at paragraph:
"
Note that Apache Lounge never made available any Win64 VC9 binaries for Apache 2.4. This means that technically there is no combination available for correctly running mod_wsgi with a Win64 VC9 version of Python 2.6 or 2.7.
History shows that users simply don't want to accept this and don't want to understand that mixing VC9 and VC10 binaries are not guaranteed to work.
"
See that? don't use Python 2.6 or 2.7 in Win64, Apache doesn't support the module for you.
But you can still download the ".so" file in here , just found which is the best and suit for you and install it into Apache. This is the tutorial how to install mod_wsig to Apache and XAMPP. Good Luck!
Rian Hariadi, Jakarta Coding

BitNami DjangoStack not 'self contained', cannot run application

I installed the Windows (32bit) BitNami DjangoStack 1.4.1.0 and elected not to install the python that came with it as I already have Python 2.7 installed.
I got the error below and also an internal server error when I clicked on the button in the introduction web page (so Appache is running ok)
enter code here
[error] mod_wsgi (pid=3990): Target WSGI script '/opt/bitnami/apps/django/scripts/django.wsgi' cannot be loaded as Python module
I found a similar question but that related to installing on Amazon. Also following through the answers it appeared that the problem is that the wsgi had been compiled against the wrong python version.
I then uninstalled BitNami and re-installed using the python version that was provided - still the same message.
I don't see how the wrong python version can be the problem if the BitNami package is self contained, i.e. comes with all the bits needed to run.
In case my previously installed version was causing the problem I remove it from the PATH environment variable.
Also the documentation for Windows seems wrong. django.conf and django.wsgi are not where the docs say they are (\Users\user\BitNami SDjangoStack projects\apps). In fact the only thing in that directory is the new project I selected on installation - no apps directory. I found the files in the BitNami directories.
Also when I typed python in the BitNami console I got python 2.7.3, not 2.7.2 which is listed in the installation guide.
I thought this package would be wonderful to help me get a production Django site running. It is now ready in the development phase to go live for testing.
What do you exactly mean with not installing Python? BitNami DjangoStack is self contained in the sense that it includes its own Python and its dependecies. Also you mentioned that you are running it on Windows but the path /opt/bitnami is the default path when installing as root in Linux. What exact options did you select during the installation?

HG reviewboard installation on Win7 x64

While it was stated that it's not the best idea to host a reviewboard for mercurial on windows evironment I stil gave it a try. So far I have not succeeded. And thus I am in search of help.
I am running Windows 7 x64 and have followed the official Installing on Windows guide.
Here I had no problems, problem occured when I chose wsgi. Now I am using Apache 2.2 32bit, python 2.5.4 32 bit and I have downloaded an apache wsgi module from: http://code.google.com/p/modwsgi/wiki/InstallationOnWindows
Strangly enough they don't have module for this particular combo (Apache 2.2|python 2.5) so I grabbed the closest thing: mod_wsgi-win32-ap22py26-3.3.so - Apache 2.2 / Python 2.6
Still I did not consider win32 would be of any problems for win64 huh ?
Well after I have told Apache2.2 in it's httpd.conf to "LoadModule wsgi_module modules/mod_wsgi.so" that I have put in modules folder, here is what it told me:
httpd.exe: Syntax error on line 129 of G:/tools/Apache2/conf/httpd.conf:
Cannot load G:/tools/Apache2/modules/mod_wsgi.so into server: %1 is not
a valid Win32 application.
Is this cause I use python 2.5 not 2.6 AND/OR windows 7 64 ? And if it's has any relation to python version - I couldn't find wsgi mod for 2.5 at least not downloadable version, only sources that need to be compiled and then some.
Has anyone faced similar problems and could advice or give hint how to load those that wsgi module ?
I'm pretty sure that mod_wsgi has to be compiled against the correct Python version, so you can't use mod_wsgi-win32-ap22py26-3.3.so with 2.5.4.
(BTW, not sure why you're still using 2.5 anyway?)

Categories

Resources