I'm trying to deploy my first django app in windows 10 (x64), so installed apache 2.4(x86), installed and build mod_wsgi (4.9.1) with python 3.8(x86) (I have microsoft visual studio 2019 installed) and configured Apache httpd.conf and httpd-vhosts.conf files.
My app runs fine, but the annoying error 500 keeps showing every now and then, and goes away by refreshing the browser every time.
There seems to be a bug with python 3.8, so decided to upgrade to python 3.10 (X86),
Reinstalled mod-wsgi and other packages using pip in new virtual environment in the same directory, and reconfigured httpd.conf accordingly. now apache service fails to start with error: "windows could not start the Apache2.4 on local computer....".
If I change httpd.conf configuration to load and use the python3.8 , Apache starts with no error (but again Error 500 keeps showing).
by the way I tried the same with python3.9 (x64) and Apache 2.4 (X64), and apache fails to start again.
Any help would be greatly appreciated.
In httpd.conf:
This configuration fails:
LoadFile "C:/Program Files (x86)/Python310-32/python310.dll"
LoadModule wsgi_module "d:/django project/unemployment project/.venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp310-win32.pyd"
WSGIPythonHome "d:/django project/unemployment project/.venv"
This configuration works:
LoadFile "C:/Program Files (x86)/Python38-32/python38.dll"
LoadModule wsgi_module "d:/django project/unemployment project/venv/lib/site-packages/mod_wsgi/server/mod_wsgi.cp38-win32.pyd"
WSGIPythonHome "d:/django project/unemployment project/venv"
Related
I am trying to host a django application on a server using apache2 and mod_wsgi.
The project itself is located at the path /usr/share/django-projects/mysite
The virtual environment is located at the path /home/zakhar/django_test/env
It's part of apache2 (2.4 version) conf file. In venv python version is 3.8.13
WSGIDaemonProcess mysite user=www-data group=www-data python-path=/usr/share/django-projects/mysite:/home/zakhar/django_test/env/lib/python3.8/site-packages python-home=/home/zakhar/django_test/env
It's last error from apache arror.log
File "/home/zakhar/django_test/env/lib/python3.8/site-packages/django/db/models/aggregates.py", in line 84
if (default := c.default) is None:
^
SyntaxError: invalid syntax
I think apache use python 3.6.9 in global env, but not in venv
I would be very grateful if someone could help me
I installed mod_wsgi in my venv and edited /etc/apache2/mods-avaible/wsgi.load
LoadModule wsgi_module "/home/zakhar/django_test/env/lib/python3.8/site-packages/mod_wsgi/server/mod_wsgi-py38.cpython-38-x86_64-linux-gnu.so"
WSGIPythonHome "/home/zakhar/django_test/env"
I have in my server two Python versions: the Python default, already present in Ubuntu Server 16.04 and Anaconda Python.
When I run the Flask application with Apache, because this is running in user www-data, the application runs in Python default, but I have to run in Anaconda installation.
How to configure to use the Anaconda Python version and how to install new modules in this version?
The path of Anaconda installed is /home/wandre/anaconda2
This is one way that worked for me to let Apache run the python module in Anaconda environment so that Flask app can run.
First is installation. Install Apache with the command sudo apt-get install apache2 apache2-bin apache2-dev. Then, install Anaconda under the directory /opt as sudo. After having Anaconda installed on /opt/anaconda2, install conda packages as below:
sudo su # Login as superuser
export PATH=/opt/anaconda2/bin:$PATH # Add conda to your path
conda install -c anaconda flask
pip install mod_wsgi
mod_wsgi-express install-module # the outputs to this is used for Apache configuration in the next step
Now you need to update the Apache configurations. This involves updating three files:
wsgi.load
Open the file /etc/apache2/mods-available/wsgi.load and add the following (this is the output from mod_wsgi-express install-module so yours could be different)
LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi-py27.so
If the LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so was originally included in this file, comment it out. Otherwise (at least from what I checked), the apache server will run the default python instead of the one in Anaconda. Next, enable the wsgi mod:
sudo a2enmod wsgi
wsgi.conf
Open the file /etc/apache2/mods-available/wsgi.conf and add the following
<IfModule mod_wsgi.c>
WSGIPythonHome /opt/anaconda2
</IfModule>
000-default.conf (your filename may be different)
Open the file /etc/apache2/sites-available/000-default.conf and add the following
WSGIDaemonProcess flaskapp python-home=/opt/anaconda2 python-path=/var/www/flask
WSGIScriptAlias / /var/www/flask/flaskapp.wsgi
<Directory /var/www/flask>
WSGIProcessGroup flaskapp
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
You are all set.
Please note that I was not able to find tutorial for setting 'Anaconda + Flask + Apache' so I referred to a post on 'Anaconda + Django + Apache'.
I'm trying to use mod_wsgi-express for a django project. This project will be served through the main instance of apache, with a proxy. My purpose is to serve a python 3 application with a mod_wsgi for python 2 installed on the "main" apache server. (I've many apps on the same server)
I've created a systemd service which should launch the mod_wsgi-express instance, using my own service file :
https://gist.github.com/frague59/87529fc28b098dd116f09be92cf66af0
and
https://gist.github.com/frague59/8de1d03800042db95c82452af280dffe
I've to mention that those scripts works on another server, same distro, same version (debian oldstable)
... but the mod_wsgi-express does not start : no error message, no log...
I've noticed that a dir is created in tmp:
/tmp/mod_wsgi-127.0.0.1:8081:993
I've tried to start the apachectl from here:
# apachectl configtest
And I have a weird message:
AH00526: Syntax error on line 241 of /tmp/mod_wsgi-127.0.0.1:8081:993/httpd.conf:
Invalid option to WSGI daemon process definition.
I posts the generated httpd.conf file for example:
https://gist.github.com/frague59/a6d8d26b704565b39f7352a7c16e07d3
Error seems to be around:
send-buffer-size=0 \
I am trying to run python on wampserver, I am following How to install Python with Wampserver as guide.
Setup Configuration:
Python 2.7.6(64-bit); wampserver2.5-Apache-2.4.9-Mysql-5.6.17-php5.5.12-64bit;
Windows 7 (64 bit)
For mod_wsgi: I tried all three 64 bit binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/#mod_wsgi
But as I add "LoadModule wsgi_module modules/mod_wsgi.so" line to load wsgi module in httpd.conf, the server fails with error "ERR_CONNECTION_REFUSED"
Any help on what am I missing?
I want to setup a Galaxy instance in my server running on CentOS and I have an issue with configuring my Apache server with uWSGI. I have installed uwsgi with pip:
pip install uwsgi
and added in my Apache configuration file the following lines:
<Location "/galaxy">
Sethandler uwsgi-handler
uWSGISocket 127.0.0.1:4001
uWSGImaxVars 512
</Location>
as instructed by the Galaxy team. Nevertheless when I restart my web server I get the following error:
Invalid command 'uWSGISocket', perhaps misspelled or defined by a mod
and it fails to start again.
I'm very new to using Apache for proxying requests so I need any help I can get.
Thank you in advance.