Apache 2.4, Python and Django on Windows - python

I am using Windows 8.1. and trying to configure XAMPP (apache 2.4, VC11) to work with Python (I have 2.7) and Django (1.7). Have downloaded mod_wsgi (VC9), changed httpd.conf but still getting Apache shut down: Any clues?
Error: Apache shutdown unexpectedly. 06:24:31 [Apache] This may be
due to a blocked port, missing dependencies, 06:24:31 [Apache]
improper privileges, a crash, or a shutdown by another method.
06:24:31 [Apache] Press the Logs button to view error logs and check
06:24:31 [Apache] the Windows Event Viewer for more clues 06:24:31
[Apache] If you need more help, copy and post this 06:24:31 [Apache]
entire log window on the forums

Since you are using python 2.7, Your Apache must be compiled with VC9, You can download the required Apache from - (https://www.apachehaus.com/cgi-bin/download.plx#APACHE24VC09). Make sure you download the 32 bit version if you are running a 32 bit python installation or the 64 bit version if your python installation is 64 bit.

Related

How to connect local PyCharm to python installed on a server? Is this even possible?

I have PyCharm on my machine (8GB RAM). I am required to to heavy data processing, and would like to use an institutionally provided server. This server has Python installed, but without any IDE. So all I see is a CUI, and it is difficult to program in such an environment.Also note that I cannot ask server admin to install software on the server for me. So, how can one connect one's local PyCharm to a python installed on a remote server? Is this even possible?
You can configure an interpreter using SSH:
Open the Add Python Interpreter dialogue
In the left-hand pane of the Add Python Interpreter dialogue, click SSH Interpreter.
Follow the wizard.
For more detailed instructions, check:
https://www.jetbrains.com/help/pycharm/configuring-remote-interpreters-via-ssh.html
Note: unfortunately, this option is not available in the PyCharm Community Edition.

how to diagnose Apache2.4 service error 7024 Incorrect function

System:
Windows 10 x64 (enterprise computer with some restrictions)
Apache 2.4 64-bit
Python 3.7.1 64-bit
mod_wsgi (built today from github using python setup.py install)
I am working on getting an Apache server with Python on a Windows machine and I have the server configured correctly in order to get the Hello World! example from mod_wsig documentation working.
If I simply launch C:\Apache24\bin\httpd.exe, this works and I see Hello World at http://localhost:5000/
Then I wanted to get it running as a service, so I call
httpd.exe -k install
In the ApacheMonitor I start the new Apache2.4 service but I get a failed to start error. In the Windows system event log it says Event ID: 7024 with a service specific error: Incorrect function.
When I run httpd.exe -k start -n "Apache2.4" -t it says Syntax OK
What I can't find is any more information about the service error. Nothing populates in the error.log file and I don't know where else to look, and I am asking for any further information on how to diagnose this.
Before I started configuring Apache to use mod_wsgi, launching the service was successful, so this happened after doing that, and I haven't configured anything else at this point.
Go to the Command Prompt move to the apache/bin folder and type
>httpd -t
This will give you more information about the error preventing Apache from start.
I was getting this error after updating my httpd.conf file. The problem was that my final xml tag in httpd.conf was unclosed </directory without the closing >.
This days I was facing the same situation, windows 10, apache24, django app, python3.8, failing to start as service, service events showing error 7024...
So, after a lot of struggling and research, I would like to add my solution even this is an old question.
The solution was to add two environment variables, no in httpd.conf, not in python code/conf but at SO level (windows > environment variables)
PYTHONHOME = c:\your\path\to\installed\python
PYTHONPATH = c:\your\path\to\installed\virtualenv
And magic! apache now works as service and the django app is always available on localhost

Apache has to be restarted dozens of times before Python responds

I have a strange issue, if I restart Apache with my DJANGO Application then static files respond just fine (like the Apache Status Page shows it is handling requests). There are no errors in the log files, and WSGI loads as far as the logfile is concerned.
The problem is that my DJANGO/Python/WSGI Application is not responding to any requests, the web page just times out. I have to restart Apache over and over again, sometimes for up to an hour before the application finally responds. The strange part is that sometimes it will restart immediately. Nothing helps, boot order has no affect, restarting the entire server has not helped. I chased down linked libraries and cleared out the duplicate loading from other requests that I have seen.
A few environment items:
Windows Server Apache 2.2
Python 2.6
Django 1.4.5
MOD_WSGI 3.5 for Windows Apache (http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi)
One last detail:
If I block HTTP and HTTPS ports using the firewall and restart Apache then enable the firewall then the service comes right up. So there seams to be some problem with active sessions and Apache/WSGI/Pyhton/Django.
Any ideas on what I can tweak in my WSGI or Apache configuration to get the application to come right up?

All my python windows services stopped working

I run several python scripts as Windows Services on Windows XP. Just now they all died. They will not restart. I have no clue what is going on. I can't seem to get an error message to give me more insight. I haven't tried to reinstall any modules yet. What Modules are used by Windows Services in python?
EDIT:
When I reinstall pywin32 I do get this error:
However after clicking the 'ok' button, module does continue to install
Found the Issue. Windows Error Log was full... So the script could not even send a message to log saying that service restarted thus it would fail and not log any error messages to boot.

MOD_WSGI difficulties on Mac OS X Snow Leopard

I've been trying to get MOD_WSGI working on Apache via XAMPP on my Mac OS X Snow Leopard all day today without any success. I've followed all the instructions, searched the internet for solutions, etc but no luck so far. Below are my exact steps and details. When I run localhost all I get is a white screen. When I remove "LoadModule wsgi_module modules/mod_wsgi.so" from httpd.conf localhost runs as expected.
Downloaded and installed Xcode.
XAMPP is already installed and working.
I Don't need to install Python as OS X already has Python 2.6 in 64-bit mode.
Download and unpack mod_wsgi-2.6.tar.gz to desktop.
Terminal "./configure --with-apxs=/Applications/XAMPP/xamppfiles/bin/apxs --with-python=/System/Library/Frameworks/Python.framework/Versions/2.6/bin/python2.6" (no errors)
Terminal "make" (message "make: Nothing to be done for `all'.")
Terminal "sudo make install" (no errors)
Add to XAMPP's httpd.conf file:
LoadModule wsgi_module modules/mod_wsgi.so
AddType text/html .py
WSGIScriptAlias /app-sample "/Applications/xampp/xamppfiles/htdocs/app-sample/main.py"
<Directory "/Applications/xampp/xamppfiles/htdocs/app-sample">
Order deny,allow
Allow from all
</Directory>
Restart Apache via XAMPP
First off, run 'make distclean' and then redo configure/make/make install for mod_wsgi. Where you have 'Terminal "make" (message "make: Nothing to be done for `all'.")' indicates there were prior build results in directory and nothing got built for that execution of make.
Next, use '.wsgi' extension instead of '.py' to ensure that you don't have a conflict with an existing definition saying that '.py' files should be executed as CGI scripts. This is one common reason for blank responses. The Apache error logs should give you clues as to this being the problem.
Also, what does your sample application do? Have you tried with a simple hello world program as per the documentation on the mod_wsgi site rather than jump to using your own program. If using your own program only, then you may possibly be causing Apache processes to crash due to some shared library conflict between Apache and Python modules being used, something else that will cause blank responses. Again, carefully check the Apache error logs for information logged at time request is made.
Finally your program could just be buggy and have bad syntax in returned HTML response causing it to not be displayed. Ask the browser to show the source for the page returned by the request and make sure it isn't malformed HTML.

Categories

Resources