mod_wsgi-express: error: no such option: --url-alias - django

I'm deploying an application with mod_wsgi-express, and I've a new error when launching the service :
oct. 12 09:15:29 Angara mod_wsgi-express[12284]: Usage: mod_wsgi-express start-server script [options]
oct. 12 09:15:29 Angara mod_wsgi-express[12284]: mod_wsgi-express: error: no such option: --url-alias /static /var/www/agenda-v3.example.tld/static --url-alias /media /var/www/agenda-v3.example.tld/media
The mod_wsgi-express application fails to launch...
I've added the --log-directory directive to route logs to the ${SERVER_PATH}/log, which works great (I can read the log files now),
Have you any idea ? It worked before...
I've checked the /var/www/agenda-v3.example.tld/media and /var/www/agenda-v3.example.tld/static directories, they exist for now.
Thanks for your help !

The problem is that WSGI_URL_ALIASES is being passed through and interpreted as a single value rather than three separate arguments.
IOW, the argument is seen as single value of:
--url-alias /static /var/www/agenda-v3.example.tld/static
What I would actually suggest you do is use setup-server to pre-setup the mod_wsgi-express directory with the options you required. The only thing your init files then need to do is apachectl start and apachectl stop. All the stuff about options is recorded in scripts in the mod_wsgi-express directory.
See the PyPi page about using setup-server.
https://pypi.python.org/pypi/mod_wsgi

Related

Termux says "'Bad Interpreter: No such file or directory"

I have a problem and hope someone can help me. I am currently trying to write a script for Termux or Termux:Task. My script currently looks like this:
#!/data/data/com.termux/files/usr/bin/bash
cd /./sdcard/www/public/
wp post list sleep 5
Every time I load the script I get the following error message:
/data/data/com.termux/files/usr/bin/wp: /usr/bin/env: bad interpreter: No such file or directory.
I've been looking for a solution to my problem for hours, unfortunately without success.
I am using an extension for Termux called "WordPress CLI". When I start termux and enter the commands individually, everything works. But as soon as I write the commands into a sh script and start it doesn't work anymore. :(
Can anyone help me?
Thanks a lot
This is simple error you can fix it by replacing !/data/data/com.termux/files/usr/bin/bash. With #!/data/data/com.termux/files/usr/bin/bash
Please tell if you get error again
Try with #!/usr/bin/env bash in the shebang line.
Termux-exec allows you to execute scripts with shebangs for traditional Unix file structures. So shebangs like #!/bin/sh and #!/usr/bin/env python should be able to run without termux-fix-shebang.
From https://wiki.termux.com/wiki/Termux-exec
According to doc:
Why do I keep getting a '/bin/sh bad interpreter' error?
This error is thrown due to access script interpreter at nonexistent
location.
Termux does not have common directories like /bin, /sbin, /usr/bin at
their standard place. There is an exception for certain devices where
/bin is a symbolic link to /system/bin, but that does not make a
difference.
Interpreters should be accessed at this directory only:
/data/data/com.termux/files/usr/bin
There are three ways to fix this:
Install termux-exec by using pkg install termux-exec. It won’t affect the current session, but after a restart should work without
any setup. Not needed if your Termux is up to date. If still not
working, try the next workaround.
Use command termux-fix-shebang to fix the shebang line of specified file.
Use termux-chroot from package proot to setup a chroot environment mimicking a normal Linux file system in Termux.
termux-fix-shebang my_script.py of second method work for me, which it modify the shebang(first line of my_script.py) from #!/usr/bin/env python to #!/data/data/com.termux/files/usr/bin/env python. Since /usr/bin/ is not exist in Android, that's why it throws the error /usr/bin/env: bad interpreter: No such file or directory. The other solution is run with python my_script.py, neither of my_script.py nor ./my_script.py.
In my test, termux-exec of the first method only work if I added correct shebang in main script(child OR child of child script no need) and ran command export LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so.
And for the issue of this question, error shows /usr/bin/env in the middle with /data/data/com.termux/files/usr/bin/wp even though the shebang of script #!/data/data/com.termux/files/usr/bin/bash looks ok, it means that wp command (located at /data/data/com.termux/files/usr/bin/wp) used inside the script contains shebang #!/usr/bin/env wp and should modify it to #!/data/data/com.termux/files/usr/bin/env wp too. termux-exec of first method should fix this specific case too(already has correct shebang in main script).

Tired of reinstalling Bitnami WAMP Stack 7.0 over and over again. Cannot install stack in a deeper directory

This is really REALLY damn frustrating. For some reason Bitnami WAMP Stack keeps on FAILING to install in a deeper directory D:\***\***\***\***\***\wampstack. It ONLY works when I'm installing in the root (one folder in D:\Bitnami\wampstack). My set up NEEDS to have the stack server installed deeper down for organization's sake, but it won't work. It keeps failing.
I then tried installing it in the root directory, then tried moving the whole folder (since IT IS supposed to be self-contained.) into the proper directory (deeper down), and then changing the ImagePath of the wampserverApache and wampserverMySQL to reflect that of the new location. IT STILL WON'T START.
I keep getting this error:
> Starting all servers... Starting MySQL Database... Exit code: 1
> Stdout:
>
> Stderr: Unknown error starting mysql Starting Apache Web Server...
> Exit code: 1 Stdout:
>
> Stderr: Unknown error starting apache
Any idea on how to fix this? Or am I just doing something extremely wrong. Please help. My OCD is killing me spent a good 3 hours on this stupid issue. I just don't understand why the installer won't let me just install in a deeper directory. It lets me change the directory during installation but it doesn't ever work. Bitnami really should fix this if they're letting you change the directory in which to install, or at least limit the choices so that the user doesn't get stuck needlessly trying to figure out the problem with the installation.
Bitnami developer here.
The problem you're facing must be related to the length of your path. This is a NTFS limitation, this is a related case:
Maximum filename length in NTFS (Windows XP and Windows Vista)?
Could you check if your path is longer than 255 characters?
Also spaces in directory names can be an issue, as all this software is ported from unix where spaces in directory names require the use of quotes around paths that contain spaces. So either check the config and put quotes around your paths that contain spaces like "folder 1/folder 2" or remove/replace the spaces in the paths.

extensions xsl and intl are missing (need them to run Magento2). I'm using Windows 8.1

I installed php7.0.15/apache2.4.25/phpMyAdmin 4.6.5.2 via xampp, but it turns out that the extensions xsl and intl are missing (need them to run Magento2).
I'm using Windows 8.1.
Both files php_xsl.dll and php_intl.dll exist in xampp/php/ext and I tried deleting the related ";" from extension=.. from in php.ini,
re-saving the php.ini and restarting apache server;
also copied in apache/bin folder the icu*.dll files from php;
BUT no success with that: still missing with magento2 Readiness Check.
Have any advise?
I have two suggestions for you---
No.1
Are you restarting the apache as administrator as I forget to do that most of the time.
No.2
Check your environment variable path. Did you set it properly.
Hope this can help!

Django WSGI Python Encoding

I have a strange issue with my Django Apache Wsgi setup. I recently moved my site to a different server. Unfortunately now the encoding is somewhat messed up. When I run a command like this:
barcode.generate_barcode("ean", "1341341234234")
the resulting image will show some special character between every digit, typically for some endocing issue. I guess it is using two bytes instead of one to represent each char or something similar.
If I run the same setup with django ./manage.py runserver comand. The resulting image is fine, no special characters added.
So I came to the conclusion this must be something with my apache2/mod_wsgi setup. But the versions are identical to my old setup, i.e. debian 6, apache2.2, mod_wsgi 3.3.2.
I would like to try a newer version of mod_wsgi but compilation fails.
Can anyone point me in the right direction to where this encoding error might have its cause? To my understanding the WSGI context somehow loads the entire python script with a wrong encoding, otherwise I cannot explain why a hardcoded string would turn out wrong on an image.
In Apache conf.d/charset:
AddDefaultCharset UTF-8
In my vhost additionally:
AddDefaultCharset UTF-8
In apache2/envvars:
export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
Envvars is used in apache runlevel script:
if [ -z "$APACHE_ENVVARS" ] ; then
APACHE_ENVVARS=$APACHE_CONFDIR/envvars
fi
I also tried to hardcode overwrite env vars in the runlevel script.
In my wsgi file:
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
But nothing seems to help. My image is still generated with broken encoding.
An upgrade of mod_wsgi to version 3.4.0 fixed it.
You can use the option lang or locale to the WSGIDaemonProcess clause.
See in https://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIDaemonProcess.html

How can i use a commandlinetool (ie. sox) via subprocess.Popen with mod_wsgi?

I have a custom django filefield that makes use of sox, a commandline audiotool. This works pretty well as long as i use the django development server. But as soon as i switch to the production server, using apache2 and mod_wsgi, mod_wsgi catches every output to stdout. This makes it impossible to use the commandline tool to evaluate the file, for example use it to check if the uploaded file really is an audio file like this:
filetype=subprocess.Popen([sox,'--i','-t','%s'%self.path], shell=False,\
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(filetype,error)=filetype.communicate()
if error:
raise EnvironmentError((1,'AudioFile error while determining audioformat: %s'%error))
Is there a way to workaround for this?
edit
the error i get is "missing filename". I am using mod_wsgi 2.5, standard with ubuntu 8.04.
edit2
What exactly happens, when i call subprocess.Popen from within django in mod_wsgi? Shouldn't subprocess stdin/stdout be independent from django stdin/stdout? In that case mod_wsgi should not affect programms called via subprocess. Is it possible to use a commandlinetool like that from mod_wsgi?
Add debug to your program to log to stderr the value of 'self.path' to ensure it is actually set to something. The message 'missing filename' suggest it may be empty. Also be aware that when running on Apache/mod_wsgi you must use absolute path names to files because the current working directory will not be the project directory like with the Django development server. Finally, Apache runs as a special user, so it needs to have appropriate read and/or write access to the directories you need it to access/write to. The path and access issues are documented in:
http://code.google.com/p/modwsgi/wiki/ApplicationIssues
BTW, for stdout issues, you really should upgrade to mod_wsgi 3.3. Read:
http://blog.dscpl.com.au/2009/04/wsgi-and-printing-to-standard-output.html