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 \
Related
I've developed an application in Django that I usually run in development mode:
python manage.py runserver
I do the same for my deployed instances - obviously a security issue that I now want to resolve.
From the Django docs, its not clear to me how to:
For simplicity sake, I picked wsgi (over asgi): https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/ . From this page, its not clear to me how my 'runserver' command changes to run the wsgi server over the development server. Should I run the wsgi.py file? That doesn't seem to do anything.
From the page above, its not clear whether wsgi is actually a server, or more a platform/type of servers. Do I need to use uwsgi/uvicorn/etc. instead?
I'm testing on windows - uvicorn is unix only, so I tried uwsgi, but thats giving me this error message: AttributeError: module 'os' has no attribute 'uname' - I guess its Unix only as well
So I'm using the docker image I was already building for deployment - uwsgi is giving me issues again because my docker image has no compiler, so I try now with gunicorn.
that should be easy: gunicorn project.wsgi, which gives me:
ModuleNotFoundError: No module named 'project/wsgi'
my folder structure looks like:
root-folder
project
wsgi.py
settings.py
django_app_1
django_app_2
manage.py
As the manual says, the gunicorn command should work as long as you run the gunicorn command from the same location as manage.py - which is what I'm doing.
I guess I'm missing something very obvious - who knows what?
The wsgi.py file just gives you a WSGI compatible application that a WSGI HTTP server (such as Gunicorn) can run.
I guess you have to run gunicorn project.wsgi from the root folder (that one containing the project module).
Typically, the directory containing manage.py and the module in which wsgi.py resides are one and the same. But not in your case.
I'm on Windows 10.
I created and git initialized a simple flask app that contains:
.git
.platform/hooks/postdeploy/01_runsomething.sh (contains "#!/bin/sh python print_helloworld.py")
.ebignore (ignores "venv")
venv
application.py
print_helloworld.py (independent Python file, contains "print('hello world')")
requirements.txt
Flask app runs fine on my personal computer.
I'm trying to upload it on Elastic Beanstalk and make it run "print_helloworld.py" periodically after deployment.
But, the flask app gets error during deployment:
2021/11/11 19:56:13.160939 [INFO] Executing instruction: RunAppDeployPostDeployHooks
2021/11/11 19:56:13.160959 [INFO] Executing platform hooks in .platform/hooks/postdeploy/
2021/11/11 19:56:13.161018 [INFO] Following platform hooks will be executed in order: [01_runsomething.sh]
2021/11/11 19:56:13.161027 [INFO] Running platform hook: .platform/hooks/postdeploy/01_runsomething.sh
2021/11/11 19:56:13.162276 [ERROR] An error occurred during execution of command [app-deploy] - [RunAppDeployPostDeployHooks]. Stop running the command. Error: Command .platform/hooks/postdeploy/01_runsomething.sh failed with error fork/exec .platform/hooks/postdeploy/01_runsomething.sh: permission denied
What can I do to solve this permission error?
I made 01_runsomething.sh executable by using Ubuntu (downloaded from Microsoft Store) on Windows 10 and used:
chmod +x .platform/hooks/postdeploy/01_runsomething.sh
git update-index .platform/hooks/postdeploy/01_runsomething.sh
Then, I checked the permission on Ubuntu (ls -l .platform/hooks/postdeploy/01_runsomething.sh), and it looks like this:
-rwxrwxrwx 1 root root 279 Nov 10 20:33 .platform/hooks/postdeploy/01_runsomething.sh
But, the flask app still returns same error on Elastic Beanstalk. Not sure if that solution works.
What can I do to solve this permission error?
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.
I'm attempting to setup a generic Pyramid project to work with uWSGI through Cherokee, but constantly get a "no app loaded" error. All the research I've done doesn't really give me much to go on. Anyone have any ideas? Please note that I 'am' using a virtualenv via virtualenvwrapper.
This is from my development.ini
[uwsgi]
socket = 127.0.0.1:2626
master = true
processes = 1
virtualenv = /home/user/.virtualenvs/pyramid/
pythonpath = /home/user/Projects/ConventionMeStatic
And this is the command I've been trying to use to launch it: /usr/bin/uwsgi --ini development.ini --plugin python.
I can post any further details but there have been no other changes made to the project itself.
You have specified a virtualenv and a pytonpath, but you have not specified which app to load.
If you have a single-file app you can load that file with the --wsgi-file option, if you have a deployment.ini file you can use the --paste option as described here
http://projects.unbit.it/uwsgi/wiki/UsePaste
or the --ini-paste shortcuts described in examples section of the uwsgi wiki
I am running Python 2.7, Virtualenv, Django 1.3, mod_wsgi, Apache application on Ubuntu 11.04.
Everything including psycopg2 etc are working great with wsgi and app are up and running.
The only issue is with Selenium. I am getting this error ONLY when I execute this from wsgi on creating firefox driver as follows:
from selenium import webdriver
wd = webdriver.Firefox()
WebDriverException Exception Value: Message: "Can't load the profile.
Profile Dir : /tmp/tmp8h7MW8"
my Selenium version is 2.5
Apache launched as root and child process are launched as user called app.
Execute the code above from same virtualenv without wsgi works just fine.
So this makes me think that it is permission issue at some level... so I tried this:
ls -l /tmp/tmp8h7MW8
>> drwxr-xr-x 3 app app 4096 2011-10-07 13:09 extensions
>> -rw-r--r-- 1 app app 2188 2011-10-07 13:09 user.js
I would appreciated it if you could point me to right direction as to what I am might be misconfiguring wsgi
Apache processes run as special user. If that temp directory is truly owned by 'app' then Apache user likely wouldn't be able to write to it.
What user does Apache run as? Are you using daemon mode and overridden what user it should run as?
So I traced firefx_binary.py and figure it out the actual error was "Connection refused" when socket_.connect(("127.0.0.1", self.profile.port)) is called.
The port value changes every time (ie: 45807, 44719, 60565)
The error occurs depends on Group setting on apache config (apache run user and group) as Graham suspected. I was playing with 2 users.
$ groups app
app : app
$ groups nreeves
nreeves : nreeves adm dialout fax cdrom floppy tape dip video plugdev fuse
I tried 3 patters and only 1 works which still confuses me and hope someone could tell me why...
# this does't work...
User=nreeves
Group=adm
# this does't work either
User=app
Group=app
# this works
User=nreeves
Group=nreeves