Reload apache within a python script on linux - python-3.x

Hi I am trying to create a python file that reloads apache2 the code of this file is:
import os
os.system("service apache2 reload")
When I use the command in the terminal everything works fine but when I run the python script I got this error:
Job for apache2.service failed.
See "systemctl status apache2.service" and "journalctl -xe" for details.
so I checked the journalctl and got this:
nov 29 13:50:19 gerrietech apachectl[37415]: Action 'graceful' failed.
nov 29 13:50:19 gerrietech apachectl[37415]: The Apache error log may have more information.
end this comes out of the error log:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.50.183. Set the 'ServerName' directive globally to suppress this message
[Mon Nov 29 13:37:35.533656 2021] [mpm_prefork:notice] [pid 36741] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:37:35.533672 2021] [core:notice] [pid 36741] AH00094: Command line: '/usr/sbin/apache2'
[Mon Nov 29 13:38:23.180736 2021] [mpm_prefork:notice] [pid 36741] AH00169: caught SIGTERM, shutting down
[Mon Nov 29 13:38:45.809351 2021] [mpm_prefork:notice] [pid 37219] AH00163: Apache/2.4.46 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Mon Nov 29 13:38:45.809422 2021] [core:notice] [pid 37219] AH00094: Command line: '/usr/sbin/apache2'
How do i fix this?

After i used /etc/init.d/apache2 reload instead of service apache2 restarti dont get any errors and the script does what it is supposed to do

Related

server 500 err when runing a github cloned project on lampp stack ubuntu

just started working on Ubuntu 22.04
I just installed lamp stack on my Ubuntu pc and it is working fine
but the problem is when i clone a repo from GitHub
when i try to run the project by a browser i see a
"localhost is currently unable to handle this request." 500 server err
i can create a simple file in projects directory and run it with no errors
and i can't either use localhost/phpmyadmin i basically get the same error
heres my ls -la log result for var/www/html
drwxr-xr-x 3 root root 4096 Jun 3 16:00 ..
-rw-rw-r-- 1 www-data www-data 10671 Jun 3 16:31 index.html
-rw-rw-r-- 1 root root 20 Jun 3 15:32 info.php
lrwxrwxrwx 1 root root 21 Jun 3 16:01 phpmyadmin -> /usr/share/phpmyadmin
drwxrwxr-x 10 mrmirzaee mrmirzaee 4096 Jun 3 17:13 Todo
Heres my error.log file for apache2 while trying to open localhost/phpmyadmin
[Fri Jun 03 18:30:05.279825 2022] [php:error] [pid 82981] [client ::1:44972] PHP Fatal error: Uncaught Error: Call to undefined function mb_strpos() in /usr/share/phpmyadmin/libraries/classes/Url.php:263\nStack trace:\n#0 /usr/share/phpmyadmin/libraries/classes/Url.php(213): PhpMyAdmin\\Url::getArgSeparator()\n#1 /usr/share/phpmyadmin/libraries/classes/Url.php(176): PhpMyAdmin\\Url::getCommonRaw()\n#2 /usr/share/phpmyadmin/libraries/classes/Core.php(752): PhpMyAdmin\\Url::getCommon()\n#3 /usr/share/phpmyadmin/libraries/classes/Core.php(339): PhpMyAdmin\\Core::linkURL()\n#4 /usr/share/phpmyadmin/libraries/classes/Core.php(366): PhpMyAdmin\\Core::getPHPDocLink()\n#5 /usr/share/phpmyadmin/libraries/classes/Core.php(994): PhpMyAdmin\\Core::warnMissingExtension()\n#6 /usr/share/phpmyadmin/libraries/common.inc.php(131): PhpMyAdmin\\Core::checkExtensions()\n#7 /usr/share/phpmyadmin/index.php(15): require_once('...')\n#8 {main}\n thrown in /usr/share/phpmyadmin/libraries/classes/Url.php on line 263
and heres the access log for that ::1 - - [03/Jun/2022:18:30:05 +0430] "GET /phpmyadmin/ HTTP/1.1" 500 185 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36" ::1 - - [03/Jun/2022:18:30:56 +0430] "-" 408 0 "-" "-"
the same log files while opening my projects :
access log : ::1 - - [03/Jun/2022:18:35:12 +0430] "GET /Todo/ HTTP/1.1" 500 185 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36"
error log : [Fri Jun 03 18:35:12.880098 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: include(E:/xampp/htdocs/todo/bootstrap/config.php): Failed to open stream: No such file or directory in /var/www/html/Todo/Bootstrap/init.php on line 3 [Fri Jun 03 18:35:12.880251 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: include(): Failed opening 'E:/xampp/htdocs/todo/bootstrap/config.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/Todo/Bootstrap/init.php on line 3 [Fri Jun 03 18:35:12.880319 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: include(E:/xampp/htdocs/todo/vendor/autoload.php): Failed to open stream: No such file or directory in /var/www/html/Todo/Bootstrap/init.php on line 4 [Fri Jun 03 18:35:12.880337 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: include(): Failed opening 'E:/xampp/htdocs/todo/vendor/autoload.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/Todo/Bootstrap/init.php on line 4 [Fri Jun 03 18:35:12.880385 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: include(E:/xampp/htdocs/todo/libs/helpers.php): Failed to open stream: No such file or directory in /var/www/html/Todo/Bootstrap/init.php on line 5 [Fri Jun 03 18:35:12.880433 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: include(): Failed opening 'E:/xampp/htdocs/todo/libs/helpers.php' for inclusion (include_path='.:/usr/share/php') in /var/www/html/Todo/Bootstrap/init.php on line 5 [Fri Jun 03 18:35:12.880457 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: Undefined variable $db_config in /var/www/html/Todo/Bootstrap/init.php on line 7 [Fri Jun 03 18:35:12.880470 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: Attempt to read property "host" on null in /var/www/html/Todo/Bootstrap/init.php on line 7 [Fri Jun 03 18:35:12.880482 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: Undefined variable $db_config in /var/www/html/Todo/Bootstrap/init.php on line 7 [Fri Jun 03 18:35:12.880492 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: Attempt to read property "db_name" on null in /var/www/html/Todo/Bootstrap/init.php on line 7 [Fri Jun 03 18:35:12.880506 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: Undefined variable $db_config in /var/www/html/Todo/Bootstrap/init.php on line 7 [Fri Jun 03 18:35:12.880537 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: Attempt to read property "user" on null in /var/www/html/Todo/Bootstrap/init.php on line 7 [Fri Jun 03 18:35:12.880548 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: Undefined variable $db_config in /var/www/html/Todo/Bootstrap/init.php on line 7 [Fri Jun 03 18:35:12.880558 2022] [php:warn] [pid 82977] [client ::1:44978] PHP Warning: Attempt to read property "pass" on null in /var/www/html/Todo/Bootstrap/init.php on line 7 [Fri Jun 03 18:35:12.880730 2022] [php:error] [pid 82977] [client ::1:44978] PHP Fatal error: Uncaught Error: Call to undefined function diePage() in /var/www/html/Todo/Bootstrap/init.php:10\nStack trace:\n#0 /var/www/html/Todo/index.php(3): include()\n#1 {main}\n thrown in /var/www/html/Todo/Bootstrap/init.php on line 10
IDK why it's returning so much errs i literally use the same project on my windows xampp
I would suggest to check the PHP version and use a compatible one. You can use command php --version on linux. I see that you are trying to run PHPmyadmin, its advised to go through its version notes and check which PHP versions it supports.
I Fixed the problem
despite my project's problem which a false addressing in files was causing it
the PhpMyAdmin was not Responding because I hadn't installed an E called mbstrings as you can see in errors there is an undefined function mbstrops() which actually needs the mbstring Extension to run correctly i just installed the package which was compatible with my php version (8.0.1) and i got everything working correctly
in order to see how to install mbstrings Extesion see this :
Askubuntu

Ubuntu 18.04 Apache automatically crashing frequently for NodeJS Angular based application in AWS EC2 and stopping

I am using Ubuntu 18.04 on AWS EC2 instance free tier, running websites on Apache server, NodeJS with PostgreSQL database. All deployments are done perfectly and web-apps works fine without any exception or error details.
However I am facing an annoying issue: this instance is stopping frequently without any exception or error logs. After rebooting instance everything starts working fine but after some time it automatically stops either in few hrs. on same day when rebooted instance or in 1-2 days after that.
Below are some Apache logs (var/log/apache2) I tried to analysed but couldn't found out what is causing this exactly:[there is error log is looks related to this:
**[Sun Jul 05 14:11:30.444362 2020] [mpm_event:notice] [pid 1007:tid 140440680164288] AH00491: caught SIGTERM, shutting down]** ]
[Sun Jul 05 13:10:44.389403 2020] [mpm_event:notice] [pid 1007:tid 140440680164288] AH00489: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sun Jul 05 13:10:44.389524 2020] [core:notice] [pid 1007:tid 140440680164288] AH00094: Command line: '/usr/sbin/apache2'
[Sun Jul 05 13:10:55.517856 2020] [proxy:error] [pid 1009:tid 140440540890880] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:4200 (localhost) failed
[Sun Jul 05 13:10:55.517921 2020] [proxy_http:error] [pid 1009:tid 140440540890880] [client 27.97.147.181:32952] AH01114: HTTP: failed to make connection to backend: localhost
[Sun Jul 05 13:10:55.969159 2020] [proxy:error] [pid 1008:tid 140440582854400] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:4200 (localhost) failed
[Sun Jul 05 13:10:55.969223 2020] [proxy_http:error] [pid 1008:tid 140440582854400] [client 27.97.147.181:25642] AH01114: HTTP: failed to make connection to backend: localhost, referer: http://xx.xx.xx.x6x/
[Sun Jul 05 13:10:59.352669 2020] [proxy:error] [pid 1009:tid 140440549283584] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:4200 (localhost) failed
[Sun Jul 05 13:10:59.352711 2020] [proxy_http:error] [pid 1009:tid 140440549283584] [client 27.97.147.181:12476] AH01114: HTTP: failed to make connection to backend: localhost
[Sun Jul 05 13:10:59.687423 2020] [proxy:error] [pid 1008:tid 140440574461696] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:4200 (localhost) failed
[Sun Jul 05 13:10:59.687463 2020] [proxy_http:error] [pid 1008:tid 140440574461696] [client 27.97.147.181:26001] AH01114: HTTP: failed to make connection to backend: localhost, referer: http://xx.xx.xx.x6x/
[Sun Jul 05 13:11:26.091717 2020] [proxy:error] [pid 1009:tid 140440557676288] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:4200 (localhost) failed
[Sun Jul 05 13:11:26.091772 2020] [proxy_http:error] [pid 1009:tid 140440557676288] [client 27.97.147.181:38107] AH01114: HTTP: failed to make connection to backend: localhost
[Sun Jul 05 13:11:26.420448 2020] [proxy:error] [pid 1009:tid 140440464520960] (111)Connection refused: AH00957: HTTP: attempt to connect to 127.0.0.1:4200 (localhost) failed
[Sun Jul 05 13:11:26.420481 2020] [proxy_http:error] [pid 1009:tid 140440464520960] [client 27.97.147.181:58238] AH01114: HTTP: failed to make connection to backend: localhost, referer: http://xx.xx.xx.x6x/
[Sun Jul 05 14:11:25.939273 2020] [proxy_http:error] [pid 1009:tid 140440557676288] (104)Connection reset by peer: [client 27.97.43.52:50804] AH01102: error reading status line from remote server localhost:4200, referer: http://domain-name.com/sockjs-node/iframe.html
[Sun Jul 05 14:11:25.980501 2020] [proxy:error] [pid 1009:tid 140440557676288] [client 27.97.43.52:50804] AH00898: Error reading from remote server returned by /__webpack_dev_server__/sockjs.bundle.js, referer: http://domain-name.com/sockjs-node/iframe.html
[Sun Jul 05 14:11:30.444362 2020] [mpm_event:notice] [pid 1007:tid 140440680164288] AH00491: caught SIGTERM, shutting down
[Sun Jul 05 14:13:35.011864 2020] [mpm_event:notice] [pid 995:tid 140269259320256] AH00489: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sun Jul 05 14:13:35.156051 2020] [core:notice] [pid 995:tid 140269259320256] AH00094: Command line: '/usr/sbin/apache2'
I had seen this type of issue before and it was DNS issue.
after lots of searches, I found out that the DNS of my domain was not registered correctly.

Apache is not running on CentOS 7 Server

I'm running a Bitrix server over a CentOS Linux 7.4.1708 machine and I can't manage to get Apache work properly. I've tried restarting the Apache service but it didn't work.
I've checked the system logs via Webadmin and it shows the following:
[Mon Mar 05 03:33:12.118466 2018] [mpm_prefork:notice] [pid 1351]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 03:33:12.118482 2018] [core:notice] [pid 1351] AH00094:
Command line: '/usr/sbin/httpd -D FOREGROUND'
[Mon Mar 05 11:19:46.641040 2018] [mpm_prefork:notice] [pid 1351]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 11:20:15.021546 2018] [suexec:notice] [pid 1360] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 11:20:15.107376 2018] [so:warn] [pid 1360] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 11:20:17.068083 2018] [mpm_prefork:notice] [pid 1360]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 11:20:17.068138 2018] [core:notice] [pid 1360] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
[Mon Mar 05 11:36:43.537842 2018] [mpm_prefork:notice] [pid 1360]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 11:37:13.314311 2018] [suexec:notice] [pid 1351] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 11:37:13.351957 2018] [so:warn] [pid 1351] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 11:37:15.361335 2018] [mpm_prefork:notice] [pid 1351]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 11:37:15.361360 2018] [core:notice] [pid 1351] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
[Mon Mar 05 11:49:01.192086 2018] [mpm_prefork:error] [pid 1351]
AH00161: server reached MaxRequestWorkers setting, consider raising
the MaxRequestWorkers setting
[Mon Mar 05 12:01:13.778293 2018] [mpm_prefork:notice] [pid 1351]
AH00170: caught SIGWINCH, shutting down gracefully
[Mon Mar 05 12:01:43.297586 2018] [suexec:notice] [pid 1383] AH01232:
suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 05 12:01:43.371237 2018] [so:warn] [pid 1383] AH01574: module
socache_shmcb_module is already loaded, skipping
[Mon Mar 05 12:01:44.932973 2018] [mpm_prefork:notice] [pid 1383]
AH00163: Apache/2.4.6 (CentOS) PHP/7.0.26 OpenSSL/1.0.2k-fips
configured -- resuming normal operations
[Mon Mar 05 12:01:44.933001 2018] [core:notice] [pid 1383] AH00094:
Command line: '/usr/sbin/httpd -f /etc/httpd/conf/httpd-scale.conf -D
FOREGROUND'
I don't have any clue on what the problem might be. Apache used to work fine until we installed a Bitrix update on the server.
Any sort of help or comment about this would be much appreciated.
Did you increase the MaxRequestWorkers setting as suggested in the logs?
Find the corresponding file:
grep -Ril MaxRequestWorkers /etc/httpd/
On CentOS usually it is /etc/httpd/conf/httpd.conf. Open the file, increase the value of MaxRequestWorkers and restart the web server for the changes to take effect:
systemctl restart httpd

What to run instead of httpd -S on Debian 8 with Apache 2.4.10?

Apache Virtual Host documentation:
If you are trying to debug your virtual host configuration, you may find the Apache -S command line switch useful. That is, type the following command:
/usr/local/apache2/bin/httpd -S
This command will dump out a description of how Apache parsed the configuration file. Careful examination of the IP addresses and server names may help uncover configuration mistakes. (See the docs for the httpd program for other command line options)
# /usr/local/apache2/bin/httpd -S
bash: /usr/local/apache2/bin/httpd: No such file or directory
# find / -type f -iname apache2
/etc/monit/monitrc.d/apache2
/etc/init.d/apache2
/etc/default/apache2
/etc/logrotate.d/apache2
/etc/bash_completion.d/apache2
/etc/cron.daily/apache2
/usr/share/php5/sapi/apache2
/usr/share/lintian/overrides/apache2
/usr/sbin/apache2
# /usr/sbin/apache2 -S
[Tue Jul 19 15:18:49.663497 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Tue Jul 19 15:18:49.663887 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Tue Jul 19 15:18:49.664071 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Tue Jul 19 15:18:49.664244 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Tue Jul 19 15:18:49.664428 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Tue Jul 19 15:18:49.684790 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_RUN_DIR} is not defined
[Tue Jul 19 15:18:49.685433 2016] [core:warn] [pid 3766] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
So, what should I be typing instead of /usr/local/apache2/bin/httpd -S on Debian 8 with Apache 2.4.10 ?
My system:
# lsb_release -da
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 8.1 (jessie)
Release: 8.1
Codename: jessie
Turnkey LAMP Debian 8 Core 14.1 LAMP Stack - Web Stack (MySQL)
$ apache2 -v
Server version: Apache/2.4.10 (Debian)
Server built: Aug 1 2015 20:53:57

Unable to stop apache using system version of python 2.7.6 instead of virtualenv version

I have recompiled python2.7.11 using:
./configure
make
make altinstall
sudo ln -s /usr/local/bin/python2.7 /usr/local/bin/python
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo /usr/local/bin/python
sudo /usr/local/bin/easy_install pip
sudo pip install virtualenv
sudo pip install virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh
I have installed django and all the dependencies checking that the pip is located in my new python version
I uninstalled the packaged version of mod_wsgi and
I have linked mod_wsgi to the new version of python by:
./configure --with-python=/usr/local/bin/python
make install
When I restart apache both 2.7.6 and 2.7.11 seem to be started:
[Wed Apr 27 01:46:21.085703 2016] [wsgi:warn] [pid 18410:tid 140116611360640] mod_wsgi: Compiled for Python/2.7.11.
[Wed Apr 27 01:46:21.085775 2016] [wsgi:warn] [pid 18410:tid 140116611360640] mod_wsgi: Runtime using Python/2.7.6.
[Wed Apr 27 01:46:21.086641 2016] [mpm_worker:notice] [pid 18410:tid 140116611360640] AH00292: Apache/2.4.7 (Ubuntu) OpenSSL/1.0.1f mod_wsgi/4.5.2 Python/2.7.6 configured -- resuming normal operations
My httpd.conf looks like:
WSGIPythonHome /home/vagrant/.virtualenvs/django_2.7.11_env
<VirtualHost *:80>
ServerName server.dev
ServerAlias www.server.dev
WSGIDaemonProcess server.dev python-path=/var/www/app:/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages
WSGIProcessGroup server.dev
## Vhost docroot
DocumentRoot "/var/www/app"
Alias "/sitemap.xml" "/var/www/app/static/sitemap.xml"
<Directory /var/www/app/static>
Require all granted
</Directory>
<Directory /var/www/wsgi-scripts>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
## Logging
ErrorLog "/var/log/apache2/av_app_nma_api_error.log"
ServerSignature Off
CustomLog "/var/log/apache2/av_app_nma_api_access.log" combined
WSGIScriptAlias / /var/www/wsgi-scripts/wsgi.py
</VirtualHost>
I am able to run the "hello world" wsgi application even though both versions of python seem to be used. However, when I use the django app I end up with an ImportError that seems to be related to the multiple versions.
[Wed Apr 27 02:34:42.956988 2016] [wsgi:info] [pid 20244:tid 140656494913280] mod_wsgi (pid=20244): Adding '/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages' to path.
[Wed Apr 27 02:34:42.957356 2016] [wsgi:info] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244, process='server.dev', application='server.dev|'): Loading WSGI script '/var/www/wsgi-scripts/wsgi.py'.
[Wed Apr 27 02:34:42.995218 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244): Target WSGI script '/var/www/wsgi-scripts/wsgi.py' cannot be loaded as Python module.
[Wed Apr 27 02:34:42.995328 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] mod_wsgi (pid=20244): Exception occurred processing WSGI script '/var/www/wsgi-scripts/wsgi.py'.
[Wed Apr 27 02:34:42.995376 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] Traceback (most recent call last):
[Wed Apr 27 02:34:42.995419 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/var/www/wsgi-scripts/wsgi.py", line 18, in <module>
[Wed Apr 27 02:34:42.995945 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.core.wsgi import get_wsgi_application
[Wed Apr 27 02:34:42.995998 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/wsgi.py", line 2, in <module>
[Wed Apr 27 02:34:42.996068 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.core.handlers.wsgi import WSGIHandler
[Wed Apr 27 02:34:42.996109 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 10, in <module>
[Wed Apr 27 02:34:42.996209 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django import http
[Wed Apr 27 02:34:42.996249 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/http/__init__.py", line 2, in <module>
[Wed Apr 27 02:34:42.996316 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.http.request import (
[Wed Apr 27 02:34:42.996355 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/http/request.py", line 10, in <module>
[Wed Apr 27 02:34:42.996499 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.core import signing
[Wed Apr 27 02:34:42.996560 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/core/signing.py", line 48, in <module>
[Wed Apr 27 02:34:42.996663 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from django.utils.crypto import constant_time_compare, salted_hmac
[Wed Apr 27 02:34:42.996705 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/home/vagrant/.virtualenvs/django_2.7.11_env/lib/python2.7/site-packages/django/utils/crypto.py", line 8, in <module>
[Wed Apr 27 02:34:42.996792 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] import hmac
[Wed Apr 27 02:34:42.996830 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] File "/usr/local/lib/python2.7/hmac.py", line 8, in <module>
[Wed Apr 27 02:34:42.997049 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] from operator import _compare_digest as compare_digest
[Wed Apr 27 02:34:42.997102 2016] [wsgi:error] [pid 20244:tid 140656494913280] [remote 192.168.56.1:1070] ImportError: cannot import name _compare_digest
Reply to #Graham: The make command fails with following:
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
apxs:Error: Command failed with rc=65536
.
make: *** [src/server/mod_wsgi.la] Error 1
Try:
make distclean
./configure --with-python=/usr/local/bin/python
LD_RUN_PATH=/usr/local/lib make
sudo make install
The LD_RUN_PATH environment variable when building embeds the directory path containing the correct library into the lookup path for the mod_wsgi.so file.

Resources