I'm getting an error trying to start apache which uses mod_wsgi 4.9.1 in a virtual environment.
On my centos 7 system, I compiled python 3.10, which is altinstalled to /usr/local/bin/python3.10
I have a virtualenv, but may have initially built mod_wsgi with an earlier version of python 3.10 (I was having trouble getting python to build correctly). However, my last attempt I used
pip install --ignore-installed --no-cache-dir mod_wsgi==4.9.1 --no-binary mod_wsgi
to try to get it to build with the latest python3.10 (I tried several pip installs, starting with just --no-cache-dir)
Note I am trying to upgrade several applications to python3.10, from centos7 yum installed python 3.6, mod_wsgi 4.7.0, which was working. So this likely has something to do with my python installation, or connecting mod_wsgi to the python installation.
I tried running mod_wsgi-express setup-server, and get these results
$ sudo LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/custom-openssl/lib /root/bin/init-mod_wsgi-express runningroutes sandbox.routes.loutilities.com routesmgr routesmgr 8002
Server URL : http://proxysvr.loutilities.com:8002/
Server Root : /etc/mod_wsgi-express/sandbox.routes.loutilities.com
Server Conf : /etc/mod_wsgi-express/sandbox.routes.loutilities.com/httpd.conf
Error Log File : /etc/mod_wsgi-express/sandbox.routes.loutilities.com/error_log (warn)
Rewrite Rules : /etc/mod_wsgi-express/sandbox.routes.loutilities.com/rewrite.conf
Environ Variables : /etc/mod_wsgi-express/sandbox.routes.loutilities.com/envvars
Control Script : /etc/mod_wsgi-express/sandbox.routes.loutilities.com/apachectl
Operating Mode : daemon
Request Capacity : 5 (1 process * 5 threads)
Request Timeout : 60 (seconds)
Startup Timeout : 15 (seconds)
Queue Backlog : 100 (connections)
Queue Timeout : 45 (seconds)
Server Capacity : 20 (event/worker), 20 (prefork)
Server Backlog : 500 (connections)
Locale Setting : en_US.UTF-8
where
$ sudo cat /root/bin/init-mod_wsgi-express
#!/bin/bash
if [[ $# -lt 5 ]] ; then
echo "usage:"
echo " init-mod_wsgi-express project servername user group port"
exit 0
fi
source /var/www/$2/venv/bin/activate
mod_wsgi-express setup-server --server-name proxysvr.loutilities.com --port $5 --user $3 --group $4 /var/www/$2/$1/$1/$1.wsgi --working-directory /var/www/$2/$1/$1/ --server-root /etc/mod_wsgi-express/$2
deactivate
but I see an error when trying to start the created apachectl file
$ sudo /etc/mod_wsgi-express/sandbox.routes.loutilities.com/apachectl start
httpd (mod_wsgi-express): Syntax error on line 163 of /etc/mod_wsgi-express/sandbox.routes.loutilities.com/httpd.conf: Cannot load /var/www/sandbox.routes.loutilities.com/venv/lib/python3.10/site-packages/mod_wsgi/server/mod_wsgi-py310.cpython-310-x86_64-linux-gnu.so into server: /var/www/sandbox.routes.loutilities.com/venv/lib/python3.10/site-packages/mod_wsgi/server/mod_wsgi-py310.cpython-310-x86_64-linux-gnu.so: undefined symbol: GENERAL_NAME_free
I notice the following from the python build directory
$ grep -R GENERAL_NAME_free .
./Modules/_ssl.c: sk_GENERAL_NAME_pop_free(names, GENERAL_NAME_free);
Binary file ./Modules/_ssl.o matches
Binary file ./python matches
Binary file ./libpython3.10.a matches Binary file
./Programs/_testembed matches
and libpython3.10.a is in /usr/local/lib and /usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu
$ find /usr/local/lib -name libpython3.10.a
/usr/local/lib/libpython3.10.a
/usr/local/lib/python3.10/config-3.10-x86_64-linux-gnu/libpython3.10.a
I'm not sure how mod_wsgi in the virtual environment should be set up to find the missing library file.
What other debugging steps should I take?
Note I also posted to https://groups.google.com/g/modwsgi about a week ago but didn't see any responses.
This was answered in https://groups.google.com/g/modwsgi/c/KZZQHpFclGA/m/9St6XuSRAAAJ
Essentially, the problem is that python is using a different openssl than apache.
Related
I'm following this tutorial : https://docs.pybossa.com/installation/vagrant/
But as I don't have rights on my windows 7 machine I used my VM to deploy vagrant & co. Once I finally got it working, a started the installation of requirements and the box is completely stuck.
Host (VM) : Linux ipf7028 3.10.0-957.1.3.el7.x86_64 #1 SMP Thu Nov 29 14:49:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Vagrant provider : default, VirtualBox
Once box finally started, I had to execute in ssh python run.py but I had an error, as I'm a newbie in python I just installed pip and did pip install -r requirements.txt that was provided.
And after some downloads, global crash with following error :
/opt/vagrant/embedded/gems/2.2.3/gems/vagrant-2.2.3/lib/vagrant/environment.rb:836:in `initialize': No space left on device # rb_sysopen - /root/.vagrant.d/perm_test_YCKSPNYMOHEIFYNPVJKQYEMPHUIXGQUN (Errno::ENOSPC)
from /opt/vagrant/embedded/gems/2.2.3/gems/vagrant-2.2.3/lib/vagrant/environment.rb:836:in `open'
from /opt/vagrant/embedded/gems/2.2.3/gems/vagrant-2.2.3/lib/vagrant/environment.rb:836:in `open'
from /opt/vagrant/embedded/gems/2.2.3/gems/vagrant-2.2.3/lib/vagrant/environment.rb:836:in `setup_home_path'
from /opt/vagrant/embedded/gems/2.2.3/gems/vagrant-2.2.3/lib/vagrant/environment.rb:135:in `initialize'
from /opt/vagrant/embedded/gems/2.2.3/gems/vagrant-2.2.3/bin/vagrant:145:in `new'
from /opt/vagrant/embedded/gems/2.2.3/gems/vagrant-2.2.3/bin/vagrant:145:in `<main>'
It is obviously something with disk space but I can't figure out where... Plus I do not have any access on the vagrant box, no command line are working... destroy, halt, ssh, status everything end up with the same error output.
The provided VagrantFile :
# -*- mode: ruby -*-
# vi: set ft=ruby :
# PyBossa Vagrantfile
VAGRANTFILE_API_VERSION = "2"
# Ansible install script for Ubuntu
$ansible_install_script = <<SCRIPT
export DEBIAN_FRONTEND=noninteractive
echo Check if Ansible existing...
if ! which ansible >/dev/null; then
echo update package index files...
apt-get update -qq
echo install Ansible...
apt-get install -qq ansible
fi
SCRIPT
$ansible_local_provisioning_script = <<SCRIPT
export DEBIAN_FRONTEND=noninteractive
export PYTHONUNBUFFERED=1
echo PyBossa provisioning with Ansible...
ansible-playbook -u vagrant /vagrant/provisioning/playbook.yml -i /vagrant/provisioning/ansible_hosts -c local
SCRIPT
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/ubuntu-16.04"
config.vm.provider "virtualbox" do |v|
v.memory = 1024
end
config.vm.network :forwarded_port, host: 5000, guest: 5000
config.vm.network :forwarded_port, host: 5001, guest: 5001
# turn off warning message `stdin: is not a tty error`
config.ssh.shell = "bash -c 'BASH_ENV=/etc/profile exec bash'"
# be sure that there is Ansible for local provisioning
config.vm.provision "shell", inline: $ansible_install_script
# do the final Ansible local provisioning
config.vm.provision "shell", inline: $ansible_local_provisioning_script
end
The box was supposed to work without any problems, even virtualenv was supposed to handle some problems about requirements... (never used before).
I am missing something ?
Thanks to this Where does Vagrant download its .box files to? I just destroy the previous vargant environment and changed its location (setting VAGRANT_HOME) where I have more space.
Im running into other issues now, but this thread is over.
when i run following code
import pyopencl as cl
cl.get_platforms()
I get error
clGetPlatformIDs failed: <unknown error -1001>
I am running python 3.6 pyopencl 2018.1.1 on aws ec2 Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64).
I have tried following things , but none of them work:
echo libnvidia-opencl.so.1 >> /etc/OpenCL/vendors/nvidia.icd
from root directory by doing sudo -i
after ssh into ubuntu ec2 instance. (initially this command wont work so i removed nvidia.icd file {rm nvidia.icd}and then this command worked. but it did not solve the error 1001 mentioned above.
echo libnvidia-opencl.so.384.111 >> /etc/OpenCL/vendors/nvidia.icd
sudo ln -s /opt/intel/opencl-1.2-3.2.1.16712/etc/intel64.icd /etc/OpenCL/vendors/nvidia.icd
sudo usermod -aG video your-user-name
sudo ln -s /usr/share/nvidia-331/nvidia.icd /etc/OpenCL/vendors
sudo ln -s /usr/share/nvidia-384/nvidia.icd /etc/OpenCL/vendors
optirun myopenclprogram
The easiest way to use OpenCL on EC2 is by using the Deep Learning Base Image, which comes with all necessary drivers and is already configured to work with P2 and P3 instance types. The image can be found at https://aws.amazon.com/marketplace/pp/B077GCH38C.
I upgraded apache from 2.4.25 to 2.4.29 due to security reasons in Mac OSX.
Also installed mod_wsgi via pip.
Now facing difficulty while restarting the apache server!
I ran this command as per the mod_wsgi docs,
> mod_wsgi-express module-config
LoadModule wsgi_module "/Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so"
WSGIPythonHome "/System/Library/Frameworks/Python.framework/Versions/2.7"
Copied the above two lines in apache.conf file and tried to start the apache server but getting the following error:
> sudo apachectl start
/usr/local/apache/bin/apachectl: line 79: 51863 Illegal instruction: 4 $HTTPD -k $ARGV
Any help would be appreciated. Thanks!
EDIT as per Graham answer:
# I upgraded the mod_wsgi
> sudo pip install --upgrade --no-cache-dir mod_wsgi
Collecting mod_wsgi
Downloading mod_wsgi-4.5.21.tar.gz (2.5MB)
100% |████████████████████████████████| 2.5MB 2.1MB/s
Installing collected packages: mod-wsgi
Found existing installation: mod-wsgi 4.5.20
Uninstalling mod-wsgi-4.5.20:
Successfully uninstalled mod-wsgi-4.5.20
Running setup.py install for mod-wsgi ... done
Successfully installed mod-wsgi-4.5.21
But when i tried:
> mod_wsgi-express start-server
Traceback (most recent call last):
File "/Library/WebServer/Documents/DSFENV/bin/mod_wsgi-express", line 11, in <module>
load_entry_point('mod-wsgi==4.5.21', 'console_scripts', 'mod_wsgi-express')()
File "/Library/WebServer/Documents/DSFENV/lib/python2.7/site-packages/mod_wsgi/server/__init__.py", line 3484, in main
cmd_start_server(args)
File "/Library/WebServer/Documents/DSFENV/lib/python2.7/site-packages/mod_wsgi/server/__init__.py", line 3332, in cmd_start_server
config = _cmd_setup_server('start-server', args, vars(options))
File "/Library/WebServer/Documents/DSFENV/lib/python2.7/site-packages/mod_wsgi/server/__init__.py", line 2999, in _cmd_setup_server
language, encoding = locale.getdefaultlocale()
File "/Library/WebServer/Documents/DSFENV/lib/python2.7/locale.py", line 543, in getdefaultlocale
return _parse_localename(localename)
File "/Library/WebServer/Documents/DSFENV/lib/python2.7/locale.py", line 475, in _parse_localename
raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8
getting the above error.
Also I have installed apache 2.4.29 following this blog:
2nd Edit
I have resolved ValueError: unknown locale: UTF-8, now the output of mod_wsgi-express start-server shows:
> mod_wsgi-express start-server
Server URL : http://localhost:8000/
Server Root : /tmp/mod_wsgi-localhost:8000:501
Server Conf : /tmp/mod_wsgi-localhost:8000:501/httpd.conf
Error Log File : /tmp/mod_wsgi-localhost:8000:501/error_log (warn)
Request Capacity : 5 (1 process * 5 threads)
Request Timeout : 60 (seconds)
Startup Timeout : 15 (seconds)
Queue Backlog : 100 (connections)
Queue Timeout : 45 (seconds)
Server Capacity : 20 (event/worker), 20 (prefork)
Server Backlog : 500 (connections)
Locale Setting : en_US.UTF-8
But when I try to do config test, still showing the same error:
> sudo apachectl configtest
/usr/local/apache/bin/apachectl: line 79: 53944 Illegal instruction: 4 $HTTPD -t
xcode version:
> xcodebuild -version
Xcode 8.3.2
Build version 8E2002
3rd EDIT as per comments:
> /usr/local/apache/bin/httpd
Illegal instruction: 4
> /Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so
-bash: /Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so: cannot execute binary file
> sys.prefix
'/System/Library/Frameworks/Python.framework/Versions/2.7'
> sys.version
'2.7.10 (default, Feb 7 2017, 00:08:15) \n[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]'
I followed this blog to install Apache 2.4.29:
http://mac-dev-env.patrickbougie.com/apache/
--with-ssl option as we need to https for the website.
4th EDIT:
> file /usr/local/apache/bin/httpd
/usr/local/apache/bin/httpd: Mach-O 64-bit executable x86_64
> file /Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so
/Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so: Mach-O universal binary with 2 architectures: [x86_64: Mach-O 64-bit bundle x86_64] [i386: Mach-O bundle i386]
/Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/mod_wsgi/server/mod_wsgi-py27.so (for architecture i386): Mach-O bundle i386
Please let me know how to proceed forward.
If you have updated your Apache installation in some way, usually the mod_wsgi.so binary from an older release should still work as Apache maintains ABI compatibility across patch level updates.
If it isn't working, then you may need to re-build mod_wsgi. If there is no newer version of mod_wsgi, you will need to force a full re-build to ensure cached binaries from pip cache are not used.
pip install --upgrade --no-cache-dir mod_wsgi
Next problem though is if you have upgraded to Xcode 9.1, Apple have further broken things by completely removing apxs, meaning that my prior workaround for Apple brokeness no longer works. In this case you need to ensure you are installing mod_wsgi 4.5.21 or later. That version only just got released with fixes to accomodate for Xcode 9.1
So try that pip command above and make sure mod_wsgi-express still works by running:
mod_wsgi-express start-server
Then validate configuration snippet to use in Apache config by running again:
mod_wsgi-express module-config
If still issues with main Apache, then ensure you do a complete stop of Apache and then a start, and not just restart. Let me know how that all goes.
UPDATE 1
Above presumes you were using Apple supplied Apache in respect of Xcode 9.1 comments. You seem to be using your own Apache, maybe form Homebrew. Still try the same thing.
As suggested by Graham:
pip install --upgrade --no-cache-dir mod_wsgi
Upgrade to mod_wsgi 4.5.22 did the trick.
I am trying to set up Salt Stack for local development, but in masterless mode.
I have copied my states (top.sls, mystate.sls) to /srv/salt.
I have followed the instructions on the local development page and the salt masterless quickstart page, but when I run
$ sudo /home/vagrant/.virtualenvs/myenv/bin/salt-call -c /home/vagrant/.virtualenvs/myenv/etc/salt --local salt.highstate -l debug
All I get is
[DEBUG ] Could not LazyLoad salt.highstate
'salt.highstate' is not available.
I'm running salt in a vagrant ubuntu/trusty64 virtualbox virtual machine on a Mac.
It seems like other modules load (I see them in the debug listing) but for some reason highstate (highstate.py?) is not being loaded.
What am I doing wrong? Is there something additional I have to do for masterless development?
I got help on #salt IRC channel from whytewolf - the problem was that the command should be state.highstate (not salt.highstate):
$ sudo /home/vagrant/.virtualenvs/myenv/bin/salt-call -c /home/vagrant/.virtualenvs/myenv/etc/salt --local state.highstate -l debug
Problem solved!
I have just installed python 2.7 using macports as:
sudo port install py27-numpy py27-scipy py27-matplotlib py27-ipython +notebook py27-pandas py27-sympy py27-nose
during the process it found some issues, mainly broken files related with py25-haslib that I managed to fix. Now it seems eveything is ok. I tested a few programs and they run as expected. Currently, I have two versions of python: 2.5 (Default, from when I worked in my former institution) and 2.7 (just installed):
which python
/usr/stsci/pyssg/Python-2.5.1/bin/python
which python2.7
/opt/local/bin/python2.7
The next move would be set the new python version 2.7 as default:
sudo port select --set python python27
sudo port select --set ipython ipython27
My question is: is there a way to go back to 2.5 in case something goes wrong?
I know a priori, nothing has to go wrong. But I have a few data reduction and analysis routines that work perfectly with the 2.5 version and I want to make sure I don´t mess up before setting the default.
if you want to revert, you can modify your .bash_profile or other login shell initialization to fix $PATH to not add "/Library/Frameworks/Python.framework/Versions/2.5/bin" to $PATH and/or to not have /usr/local/bin appear before /usr/bin on $PATH.
If you want to permanently remove the python.org installed version,
paste the following lines up to and including the chmod into a posix-
compatible shell:
tmpfile=/tmp/generate_file_list
cat <<"NOEXPAND" > "${tmpfile}"
#!/bin/sh
version="${1:-"2.5"}"
file -h /usr/local/bin/* | grep \
"symbolic link to ../../../Library/Frameworks/Python.framework/"\
"Versions/${version}" | cut -d : -f 1
echo "/Library/Frameworks/Python.framework/Versions/${version}"
echo "/Applications/Python ${version}"
set -- Applications Documentation Framework ProfileChanges \
SystemFixes UnixTools
for package do
echo "/Library/Receipts/Python${package}-${version}.pkg"
done
NOEXPAND
chmod ug+x ${tmpfile}
...excripted from troubleshooting question on python website