How to get apache to use python3.6 and its modules? - apache

I have a website written in flask and built for python3.6. I am trying to deploy my website using apache and have been having issues.
I installed wsgi using the command:
sudo apt-get install libapache2-mod-wsgi-py3
I installed python3.6 using:
sudo apt-get install python3.6.
Because it is a server dedicated to just this single site I installed my python modules globally using pip3.6 instead of in a virtualenv so all my required/installed modules are located at /usr/local/lib/python3.6/dist-packages/.
I haven't been able to figure out how to get apache to use python3.6 and its modules. By default the version of python apache is using to serve is 3.5, the systems default python3 version (I verified this by printing sys.version_info in my .wsgi file). Because of this it none of my modules are in the path.
After looking around I found the apache config options WSGIPythonHome and WSGIPythonPath. I have tried adding these to my apache.confin different combinations but nothing has worked. Below is what I tried and what the errors were.
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/lib/python3.6
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/lib/python3.6
WSGIPythonPath /usr/local/lib/python3.6
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/
WSGIPythonPath /usr/local/lib/python3.6
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/lib/python3.6
WSGIPythonPath /usr/local/lib/python3.6
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
# /etc/apache2/apache.conf
WSGIPythonHome /usr/local/lib/python3.6
WSGIPythonPath /usr/local/lib/python3.6/dist-packages
# /var/log/apache2/error.log
Current thread 0x00007fc69bac4e00 (most recent call first):
[Sun Jan 14 23:02:04.732187 2018] [core:notice] [pid 7139:tid 140490992012800] AH00051: child pid 7154 exit signal Aborted (6), possible coredump in /etc/apache2
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
# /etc/apache2/apache.conf
WSGIPythonPath /usr/local/lib/python3.6
# /var/log/apache2/error.log
Using python version 3.5
Module flask not found
# /etc/apache2/apache.conf
WSGIPythonPath /usr/local/lib/python3.6/dist-packages
# /var/log/apache2/error.log
Using python version 3.5
Module flask not found
Anyway, I think I'm on the right track but can not figure out quite what I am doing wrong. It seems that I am not using the correct PythonHome but I'm not sure what it should be if not one of the above.
Any help would be greatly appreciated.

You can't force mod_wsgi compiled for one Python version to use a different Python installation for a different version. This is because mod_wsgi actually links the Python library for the version it was compiled for, it doesn't just run the python program of some arbitrary version.
The only thing you can do is uninstall mod_wsgi from system packages (which uses Python 3.5) and install mod_wsgi from source code yourself and compile it against Python 3.6.
Also, neither of the paths you gave WSGIPythonHome and WSGIPythonPath were correct anyway. When you install mod_wsgi from source code, don't set those directives as they will continue to screw things up.

Related

Impossible to import flask_cors with apache2, mod_wsgi under Python3.5 on a Raspberry pi

I try to setup a website based on Flask on a Raspberry Pi 3B+, with Apache2 (2.4.25), and mod_wsgi, but I am unable to import the module flask_cors in Python3.5...
I installed mod_wsgi with the command ssudo apt-get install libapache2-mod-wsgi
Because I only plan on using the Raspberry for hosting my website, I tried to install the packages needed by Flask system-wide, with the version 3.5 of Python, with the following command: pip3 install -r requirements.txt where requirements.txt is the following:
click==6.7
Flask==0.12.3
Flask-Cors==3.0.3
itsdangerous==0.24
Jinja2==2.9.6
MarkupSafe==1.0
six==1.11.0
Werkzeug==0.12.2
Requests==2.20.0
I think I understood that on a Raspi, it is best to import the modules wit the command pip3 install -U <module> because the packages are not installed on the default location for python, which is confirmed in my case by the following command python -m site that yields the following information:
sys.path = [
'/home/pi/.local/lib/python3.5/site-packages',
'/usr/lib/python35.zip',
'/usr/lib/python3.5',
'/usr/lib/python3.5/plat-arm-linux-gnueabihf',
'/usr/lib/python3.5/lib-dynload',
'/usr/local/lib/python3.5/dist-packages',
'/usr/local/lib/python3.5/dist-packages/virtualenv-16.1.0-py3.5.egg',
'/usr/lib/python3/dist-packages',
]
USER_BASE: '/home/pi/.local' (exists)
USER_SITE: '/home/pi/.local/lib/python3.5/site-packages' (exists)
ENABLE_USER_SITE: True
My Flask and dependencies are indeed installed in the /home/pi/.local/lib/python3.5/site-packages folder. But this does not seem to be a problem because when checking for importing on a python shell, everything seems fine systemwide:
pi#raspberrypi:~ $ python3
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from flask_cors import CORS
>>>
Knowing that, I tried to put the following files to setup my apache server:
flaskregul.conf in the folder /etc/apache2/sites-enabled:
<VirtualHost *:80>
WSGIScriptAlias / /var/www/flaskregul/flaskregul.wsgi
Alias /static/ /var/www/flaskregul/dist/static/
<Directory /var/www/flaskregul/dist/static>
WSGIProcessGroup flaskregul
WSGIApplicationGroup %{GLOBAL}
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/flask.monnomdedomaine.com.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
flaskregul.wsgi in /var/www/flaskregul:
import sys
sys.path.insert(0,"/var/www/flaskregul") # path to my __init__.py file
sys.path.insert(0,"/home/pi/.local/lib/python3.5/site-packages") # path to the site-packages folder where the modules are installed by pip3
from __init__ import app as application
__init__.py in /var/www/flaskregul:
from flask import Flask
from flask_cors import CORS
I encounter an impossibilty to specifically import the flask_cors module, because the launching of the file __init__.py yields the following errors in the file /var/log/apache2/flask.monnomdedomaine.com.log:
[Sat Nov 10 00:37:22.220394 2018] [wsgi:error] [pid 6804:tid 1955591216] [client 192.168.1.67:33550] mod_wsgi (pid=6804): Target WSGI script '/var/www/flaskregul/flaskregul.wsgi' cannot be loaded as Python module.
[Sat Nov 10 00:37:22.220972 2018] [wsgi:error] [pid 6804:tid 1955591216] [client 192.168.1.67:33550] mod_wsgi (pid=6804): Exception occurred processing WSGI script '/var/www/flaskregul/flaskregul.wsgi'.
[Sat Nov 10 00:37:22.221936 2018] [wsgi:error] [pid 6804:tid 1955591216] [client 192.168.1.67:33550] Traceback (most recent call last):
[Sat Nov 10 00:37:22.222365 2018] [wsgi:error] [pid 6804:tid 1955591216] [client 192.168.1.67:33550] File "/var/www/flaskregul/flaskregul.wsgi", line 1, in <module>
[Sat Nov 10 00:37:22.222395 2018] [wsgi:error] [pid 6804:tid 1955591216] [client 192.168.1.67:33550] from __init__ import app as application
[Sat Nov 10 00:37:22.222445 2018] [wsgi:error] [pid 6804:tid 1955591216] [client 192.168.1.67:33550] File "/var/www/flaskregul/__init__.py", line 2, in <module>
[Sat Nov 10 00:37:22.222463 2018] [wsgi:error] [pid 6804:tid 1955591216] [client 192.168.1.67:33550] from flask_cors import CORS
[Sat Nov 10 00:37:22.222557 2018] [wsgi:error] [pid 6804:tid 1955591216] [client 192.168.1.67:33550] ImportError: No module named 'flask_cors'
Whereas the import of Flask seems fine...
I've tried to debug this by changing the WSGI script file by this one:
import sys
sys.path.insert(0,"/var/www/flaskregul")
sys.path.insert(0,"/home/pi/.local/lib/python3.5/site-packages")
def application(environ, start_response):
status = '200 OK'
output = u''
output += u'sys.version = %s\n' % repr(sys.version)
output += u'sys.prefix = %s\n' % repr(sys.prefix)
output += u'sys.path = %s\n' % repr(sys.path)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output.encode('UTF-8')]
This is a piece of advice the advice on this web page from mod_wsgi: https://modwsgi.readthedocs.io/en/develop/user-guides/checking-your-installation.html. When opening the webpage, I obtain this result:
sys.version = '3.5.3 (default, Sep 27 2018, 17:25:39) \n[GCC 6.3.0 20170516]'
sys.prefix = '/usr'
sys.path = ['/home/pi/.local/lib/python3.5/site-packages', '/var/www/flaskregul', '/usr/lib/python35.zip', '/usr/lib/python3.5', '/usr/lib/python3.5/plat-arm-linux-gnueabihf', '/usr/lib/python3.5/lib-dynload', '/usr/local/lib/python3.5/dist-packages', '/usr/local/lib/python3.5/dist-packages/virtualenv-16.1.0-py3.5.egg', '/usr/lib/python3/dist-packages']
I have the impression that the path is correct! I actually succeed in importing my own modules located in the /var/www/flaskregul location...
I am lost, I don't understand why specifically the module flask_cors is unavaiblable, because it is indeed in the path:
pi#raspberrypi:~/.local/lib/python3.5/site-packages $ l | grep flask
drwxr-xr-x 5 pi pi 4096 nov. 9 23:30 flask
drwxr-xr-x 3 pi pi 4096 nov. 10 00:08 flask_cors
pi#raspberrypi:~/.local/lib/python3.5/site-packages $ l flask_cors
total 44
-rw-r--r-- 1 pi pi 13771 nov. 10 00:08 core.py
-rw-r--r-- 1 pi pi 4937 nov. 10 00:08 decorator.py
-rw-r--r-- 1 pi pi 7405 nov. 10 00:08 extension.py
-rw-r--r-- 1 pi pi 924 nov. 10 00:08 __init__.py
drwxr-xr-x 2 pi pi 4096 nov. 10 00:08 __pycache__
-rw-r--r-- 1 pi pi 22 nov. 10 00:08 version.py
Any help would be very much appreciated! I am currently losing my hair at a worriyng rate!
Oh my god I solved it in a desperate try before giving up.
I executed the following commands on a shell: (pip is the pip of the python3.5 /!\)
pip uninstall flask
pip uninstall flask_cors
sudo pip install --upgrade pip
hash -d pip
sudo pip install -U flask
sudo pip install -U flask_cors
Website up and running! :D

httpd mod_wsgi python3 pyramid Service Temporary unavaliabe

Shortly what i've done:
I downloaded python 3.5 sources, extracted and compiled them with
`
./configure --enable-shared --prefix=/usr/local/lib
make&&make install
Then python couldn't find a libpython3.5m.so.1.0 so i've ran
export LD_LIBRARY_PATH=/usr/local/lib
I've installed mod_wsgi using pip3.5 install mod_wsgi.
I also tried to install it from sources (from here http://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz) using
./configure --with-python=/usr/local/bin/python3.5
make
make install
But it finished like that
`
/usr/lib64/apr-1/build/libtool --silent --mode=link gcc -o mod_wsgi.la -rpath /usr/lib64/httpd/modules -module -avoid-version mod_wsgi.lo -L/usr/local/lib -L/usr/local/lib/python3.5/config -lpython3.5 -lpthread -ldl -lutil -lrt -lm
/usr/bin/ld: cannot find -lpython3.5
collect2: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
...
So i proceeded with modwsgi form pip but lld said that it's still 2th python so in it
`
(env) [root#spiralarms mod_wsgi-3.4]# ldd /usr/lib64/httpd/modules/mod_wsgi.so
linux-vdso.so.1 => (0x00007fffc3fae000)
libpython2.6.so.1.0 => /usr/lib64/libpython2.6.so.1.0 (0x00007fa1ea4c4000)
I've created virtualenv in /srv/modwsgi/env and installed pyramid
Created a started scaffold with pcreate -s starter myapp,activated venv, ran python setup.py install and created the guestbook.wsgi script
from pyramid.paster import get_app, setup_logging
ini_path = '/srv/env/bin/myapp/production.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')
then i chowned the whole env dir to apache:apache
In /etc/httpd/conf.d/ i've created guestbook.conf
`
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess guestbook user=apache group=apache threads=4 \
python-path=/srv/modwsgi/env/lib/python3.5/site-packages
WSGIPythonHome /srv/modwsgi/env/lib/python3.5/
WSGIScriptAlias /guestbook /srv/modwsgi/env/guestbook.wsgi
<Directory /srv/modwsgi/env>
WSGIProcessGroup guestbook
Order allow,deny
Allow from all
</Directory>
and finally i ran it in browser and it says
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.
Apache/2.2.15 (CentOS) Server at spiralarms.org Port 80
There's nothing new in error log when i try to access this page
UPDATE:
I tried running a simple wsgi application
import sys
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'+str(sys.version_info)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
and it appears that mod_wsgi uses python 2, but it should use 3.
UPDATE:
I finally compiled and installed modwsgi (following this https://github.com/GrahamDumpleton/mod_wsgi/issues/101 (see last post)) and now it have problems with importing encodings module
Current thread 0x00007f45a4cfd7e0 (most recent call first):
[Mon Mar 21 16:33:56 2016] [notice] child pid 7325 exit signal Aborted (6)
[Mon Mar 21 16:33:56 2016] [notice] child pid 7326 exit signal Aborted (6)
[Mon Mar 21 16:33:56 2016] [notice] child pid 7327 exit signal Aborted (6)
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f45a4cfd7e0 (most recent call first):
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f45a4cfd7e0 (most recent call first):
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Current thread 0x00007f45a4cfd7e0 (most recent call first):
ImportError: No module named 'encodings'
UPDATE: Without WSGIPythonHome it doesn't complains about encodings but now it gives 'internal server error'
UPDATE: Finally found logs with weird name 'dummy host' and the error was i didn't have this line in my config WSGISocketPrefix /var/run/wsgi
Finally got it to work!
The log file is called (by default)
dummy-host.example.com-error_log and located in the apache log directory
Here are my configs (they are designed with no VirtualHosts for simplicity)
guestbook.conf (for pyramid apps)
LoadModule wsgi_module modules/mod_wsgi.so
WSGISocketPrefix /var/run/wsgi #don't forget this line
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess guestbook user=apache group=apache threads=4 \
python-path=/srv/modwsgi/env/lib/python3.5/site-packages
#python-path=/usr/local/lib/python3.5/site-packages
WSGIScriptAlias /guestbook /srv/modwsgi/env/guestbook.wsgi
<Directory /srv/modwsgi/env>
WSGIProcessGroup guestbook
Order allow,deny
Allow from all
</Directory>
Here is guestbook.wsgi
from pyramid.paster import get_app, setup_logging
ini_path = '/srv/modwsgi/env/guestbook-0.0/production.ini' #use a full path cause it will be runned from apache directory
setup_logging(ini_path)
application = get_app(ini_path, 'main')
For non-pyramid apps (hello world example that shows our python version)
hellowsgi.conf:
#LoadModule wsgi_module modules/mod_wsgi.so uncomment this if it's not in other configs or better put it in the global config
WSGIScriptAlias /hello /srv/modwsgi/hello.wsgi
hello.wsgi:
import sys
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'+str(sys.version_info)
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [bytes(output,'utf-8')] # use bytes for python 3 wsgi
Also don't forget to give access to apache for all the files.
I have written an article on this (in russian)

Unable to start Apache 2.4.18 on Windows

I try to start up my HTTP service by the following procedure:
Startup easyPHP DevServer 16.1
Open Dashboard
Opens on the local machine 127.0.0.1:1111
Try to start the HTTP server using Apache 2.4.18
opens Apache page with VC11 compiler and server with
php version 5.6.17 listening on port 80.
Clicking on the Start button results in a short execution
and then no result. Both the error and access logs are empty.
Any suggestions are appreciated.
In order to properly execute PHP7 you must allready install the Redistribuable Visual C++ V14 (as shown in the PHP7 information detail on easyphp dashboard)
You can find it out here https://www.microsoft.com/download/details.aspx?id=48145
Currently PHP7 is only available in easyPHP in 32bits version, so install the compatible version of VC14.
But soon I hope we can use the x64 PHP7 version, and then you must install the x64 VC14 version
Windows 7 SP1 box, EasyPhp-DevServer-16.1.
Since I have a website to migrate, I decided to update EasyPHP on my computer to start with fresh-up-to-date versions of PHP, Apache, MySQL. Maybe I shouldn't have... the TaskBar icon and admin interface have changed, nothing works like before.
But I am stubborn, and I want it to work. So I try to run something, and it is not. Here are the symptoms, very close to Richard's:
Trying to start Apache 2.4.18, choosing PHP 7.0.2. Click on green "Start" button, it turns into a red "Stop" button. Everything is OK? Nope. Clicking on the "Error log" button, the page comes back to previous state with green "Start" button and nothing in the error log textarea.
OK, so I choose PHP 5.6.17 and click on "Start". I have popups claiming for instance "bz2: Unable to initialize module. Module compiled with module API=20131226. PHP compiled with module API=20121212. These options need to match."
The button turns to red "Stop", and clicking on "Error log" button produces this output:
PHP Warning: PHP Startup: bz2: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: gd: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: mbstring: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: mysql: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: mysqli: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: pdo_mysql: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: pdo_sqlite: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: sockets: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: sqlite3: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
PHP Warning: PHP Startup: xsl: Unable to initialize module\nModule compiled with module API=20131226\nPHP compiled with module API=20121212\nThese options need to match\n in Unknown on line 0
[Mon Feb 22 16:51:45.788809 2016] [mpm_winnt:notice] [pid 3292:tid 236] AH00455: Apache/2.4.18 (Win32) PHP/5.6.17 configured -- resuming normal operations
[Mon Feb 22 16:51:45.789809 2016] [mpm_winnt:notice] [pid 3292:tid 236] AH00456: Apache Lounge VC11 Server built: Dec 11 2015 11:26:53
[Mon Feb 22 16:51:45.789809 2016] [core:notice] [pid 3292:tid 236] AH00094: Command line: '..\\eds-binaries\\httpserver\\apache2418x160222160722\\bin\\eds-httpserver.exe -d C:/BIN/EasyPHP-Devserver-16.1/eds-binaries/httpserver/apache2418x160222160722'
[Mon Feb 22 16:51:45.797809 2016] [mpm_winnt:notice] [pid 3292:tid 236] AH00418: Parent: Created child process 2568
Xdebug requires Zend Engine API version 220131226.
The Zend Engine API version 220121212 which is installed, is outdated.
Since Apache seems to be running, I then launch MySQL. Then I try to run PHPMyAdmin. Here is the resulting message:
phpMyAdmin - Error
The mbstring extension is missing. Please check your PHP configuration.
Of course, since this extension didn't manage to be initialized!
So, here are my complementary questions to Richard's:
What can cause Apache to neither launch nor write any log when choosing PHP 7.0.2?
What can cause Apache to not initialize modules when launching with PHP 5.6.17?
Thanks for any clue,
Seagram
Hello again,
I found out an answer to myself for question 2. that may interest others:
When I installed EasyPHP-DevServer-16.1, I didn't uninstall EasyPHP-DevServer-14.1VC11. In order to have another development working months ago, I have modified my PATH environment variable to point to the php executable in this version.
Now I have removed this path reference in the PATH variable. I also exited from EasyPHP TaskBar icon. THIS IS IMPORTANT in order for this tool to forget the old PATH value. Then I restarted it, clicked on DashBoard again and launched Apache.
Now Apache starts smoothly with PHP 5.6.17 and the error log file contains only:
[Mon Feb 22 17:16:20.295146 2016] [core:warn] [pid 6652:tid 236] AH00098: pid file C:/BIN/EasyPHP-Devserver-16.1/eds-binaries/httpserver/apache2418x160222160722/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Mon Feb 22 17:16:20.313147 2016] [mpm_winnt:notice] [pid 6652:tid 236] AH00455: Apache/2.4.18 (Win32) PHP/5.6.17 configured -- resuming normal operations
[Mon Feb 22 17:16:20.313147 2016] [mpm_winnt:notice] [pid 6652:tid 236] AH00456: Apache Lounge VC11 Server built: Dec 11 2015 11:26:53
[Mon Feb 22 17:16:20.313147 2016] [core:notice] [pid 6652:tid 236] AH00094: Command line: '..\\eds-binaries\\httpserver\\apache2418x160222160722\\bin\\eds-httpserver.exe -d C:/BIN/EasyPHP-Devserver-16.1/eds-binaries/httpserver/apache2418x160222160722'
[Mon Feb 22 17:16:20.321147 2016] [mpm_winnt:notice] [pid 6652:tid 236] AH00418: Parent: Created child process 4052
[Mon Feb 22 17:16:20.895180 2016] [mpm_winnt:notice] [pid 4052:tid 316] AH00354: Child: Starting 64 worker threads.
However, with PHP 7.0.2., Apache keeps on not starting and doesn't trace anything in error log.
Something else is missing...

Apache server doesn't start if try to load mod_wsgi

I'm trying to move my project from the development server to an Apache server.
I run on a Windows 8.1 x64 machine and Python 2.7
I installed Apache 2.2.25 x86 and everything went fine, the server is active; then I downloaded the precompiled mod_wsgi-3.4.ap22.win32-py2.7 (the x86 version to match the version of Apache).
I moved the mod_wsgi.so into the modules folder of the Apache installation and added this line: LoadModule wsgi_module modules/mod_wsgi.so to the httpd config; then, when I try to restart the server it fails leaving this error log:
[Fri Jan 10 18:53:18 2014] [notice] Parent: Received restart signal -- Restarting the server.
[Fri Jan 10 18:53:18 2014] [notice] Child 9772: Exit event signaled. Child process is ending.
httpd.exe: Syntax error on line 130 of C:/Program Files (x86)/Apache Software Foundation/Apache2.2/conf/httpd.conf: Cannot load C:/Program Files (x86)/Apache Software Foundation/Apache2.2/modules/mod_wsgi.so into server: **Impossible to find the specified module**
[Fri Jan 10 18:53:18 2014] [warn] (OS 995)**I/O operation terminated because of the thread's exit or the application's request.** : winnt_accept: Asynchronous AcceptEx failed.
[Fri Jan 10 18:53:19 2014] [notice] Child 9772: Released the start mutex
[Fri Jan 10 18:53:20 2014] [notice] Child 9772: All worker threads have exited.
[Fri Jan 10 18:53:20 2014] [notice] Child 9772: Child process is exiting
note: the bold (**) parts where in my native language and I simply translated them.
I made sure that the module was actually called mod_wsgi.so so I can't really see where's the problem.
Edit: found the problem. Python (and therfore MySQL pyton mod) were x64 and not x86. Installed the right versions of both and it works just fine.
The key seems to be this:
Cannot load C:/Program Files (x86)/Apache Software Foundation/Apache2.2/modules/mod_wsgi.so into server: **Impossible to find the specified module**
This seems pretty clear. Either that file doesn't exist on your server, or if it does, Apache can't read it. Is it readable by EVERYONE?

Configure mod_wsgi 3.3 with Apache2.2 on Windows

I was able to compile mod_wsgi for Python 2.5.4. It is now loaded into apache modules. I confirmed it by command
httpd.exe -M
.
.
wsgi_module(shared)
php5_module(shared)
But I am unable to run a test file(hello.wsgi), it is located in folder c:/apache/htdocs/wsgi : so the path of file becomes c:/apache/htdocs/wsgi/hello.wsgi
My hello.wsgi file contains:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
I added the following lines to httpd.conf:
LoadModule wsgi_module modules/mod_wsgi.so
<IfModule wsgi_module>
WSGIScriptAlias /wsgi/ "c:/apache/htdocs/wsgi/hello.wsgi"
<Directory "c:/apache/htdocs/wsgi">
Order deny,allow
allow from All
</Directory>
</IfModule>
And my Apache Error Log is :
[Sat Nov 19 15:29:32 2011] [warn] pid file C:/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run?
[Sat Nov 19 15:29:32 2011] [warn] mod_wsgi: Compiled for Python/2.5.
[Sat Nov 19 15:29:32 2011] [warn] mod_wsgi: Runtime using Python/2.5.4.
[Sat Nov 19 15:29:33 2011] [notice] Apache/2.2.21 (Win32) mod_wsgi/3.3 Python/2.5.4 PHP/5.3.8 configured -- resuming normal operations
[Sat Nov 19 15:29:33 2011] [notice] Server built: Sep 9 2011 10:26:10
[Sat Nov 19 15:29:33 2011] [notice] Parent: Created child process 2296
[Sat Nov 19 15:29:33 2011] [warn] mod_wsgi: Compiled for Python/2.5.
[Sat Nov 19 15:29:33 2011] [warn] mod_wsgi: Runtime using Python/2.5.4.
[Sat Nov 19 15:29:33 2011] [notice] Child 2296: Child process is running
[Sat Nov 19 15:29:33 2011] [notice] Child 2296: Acquired the start mutex.
[Sat Nov 19 15:29:33 2011] [notice] Child 2296: Starting 64 worker threads.
[Sat Nov 19 15:29:33 2011] [notice] Child 2296: Starting thread to listen on port 80.
[Sat Nov 19 15:30:21 2011] [error] [client 127.0.0.1] File does not exist: C:/apache/htdocs/wsgi
Update
I removed the trailing slash from alias, i have moved my wsgi folder from htdocs to apache & created a vhost file:
<VirtualHost 127.0.0.1:80>
<Directory "C:/apache/wsgi">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName 127.0.0.1
ServerAlias 127.0.0.1
WSGIScriptAlias /wsgi "C:/apache/wsgi/hello.wsgi"
DocumentRoot "C:/apache/wsgi"
ErrorLog "C:/apache/logs/127.0.0.1.err"
CustomLog "C:/apache/logs/127.0.0.1.log" combined
</VirtualHost>
But now my Apache is giving some windows error like:
Faulting application name: httpd.exe, version: 2.2.21.0, time stamp: 0x4e6a3015
Faulting module name: ntdll.dll, version: 6.1.7601.17514, time stamp: 0x4ce7ba58
Exception code: 0xc0000005
Fault offset: 0x00038da9
Faulting process id: 0xc4c
Faulting application start time: 0x01cca6c0f9ccd446
Faulting application path: C:\apache\bin\httpd.exe
Faulting module path: C:\Windows\SysWOW64\ntdll.dll
Report Id: 3ba0b9e0-12b4-11e1-b285-005056c00008
Need Some Help.
Thanks.
This sounds like the error that I had when the Visual C++ 2008 Redistributable (msvcr90.dll) was not installed on the system. But first, please check (with Dependency Walker) that httpd.exe and mod_wsgi.so are using exactly the same msvcr90.dll:
same name
same directory
same version
same timestamp
If they are using different DLL names (e.g. msvcr90.dll and msvcr100.dll) then you must recompile both with the same compiler (e.g. Visual Studio 2008).
If they are using the same DLL name, but different versions or in different directories, then you might be having the same problem that I had, with BitNami DjangoStack.
Because msvcr90.dll was not installed system-wide in C:\Windows\WinSxS, httpd was only able to run at all because there was an "xcopy deployment" of the side-by-side assembly in the same directory as httpd.exe:
Microsoft.VC90.CRT.manifest
msvcr90.dll
If these files had not been present, it would have failed due to a missing dependency on msvcr90.dll, or else with this error:
This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem.
(i.e. the DLL was found but without a manifest to make it valid).
Although httpd.exe runs this way, it is not able to reliably load a DLL that also uses msvcr90.dll:
If the DLL has an "xcopy deployment" in its OWN directory, then it will load another copy of the DLL into the process (because it's a different copy of the DLL?). This results in a second heap in the process memory space, which can crash the process if memory is passed between the DLL and httpd (allocated by one and freed by the other). I think this is what you're seeing.
If the DLL does not have an "xcopy deployment" in its own directory, then it will fail to load with a SideBySide or Windows Error Reporting error in the System event log.
You can see more about this kind of problem on Python bug 4120, although this is not a clear, complete and definitive explanation of the problem, and I have not been able to find one yet.
The only reliable way I found to run this stack was to install the Visual C++ 2008 redistributable system-wide, which places a copy of msvcr90.dll in a subdirectory of C:\Windows\WinSxS along with a manifest to make it work.
This should (I think) cause Windows to completely ignore the Microsoft.VC90.CRT.manifest and msvcr90.dll files in the application and DLL directories. Both should use the same DLL in C:\Windows\WinSxS, and it should only be loaded into the process once.