Apache不提供我的Python应用程序

所以这里是我的Apacheconfiguration:

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so <VirtualHost *:80> ServerAdmin [email protected] ServerName 31.220.49.197 WSGIDaemonProcess ts threads=25 WSGIProcessGroup ts Alias /static /home/email-validator/static WSGIScriptAlias / /home/email-validator/index.wsgi # Set access permission <Directory /> Allow from all Require all granted </Directory> </VirtualHost> 

这是我的index.wsgi:

 import os import sys import site # Add the app's directory to the PYTHONPATH sys.path.append('/home/email-validator') sys.path.append('/home/email-validator/email_validator') os.environ['DJANGO_SETTINGS_MODULE'] = 'email_validator.settings' os.environ['PYTHON_EGG_CACHE'] = '/tmp' import django.core.handlers.wsgi application = django.core.handlers.wsgi.WSGIHandler() 

编辑:apache error.log

 [Sat Nov 15 12:28:09.374301 2014] [mpm_event:notice] [pid 3827:tid 3074431616] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Sat Nov 15 12:28:09.374426 2014] [core:notice] [pid 3827:tid 3074431616] AH00094: Command line: '/usr/sbin/apache2' [Sat Nov 15 12:32:45.009711 2014] [mpm_event:notice] [pid 3827:tid 3074431616] AH00491: caught SIGTERM, shutting down [Sat Nov 15 12:32:46.137115 2014] [so:warn] [pid 4297:tid 3074935424] AH01574: module wsgi_module is already loaded, skipping [Sat Nov 15 12:32:46.142088 2014] [mpm_event:notice] [pid 4298:tid 3074935424] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Sat Nov 15 12:32:46.142125 2014] [core:notice] [pid 4298:tid 3074935424] AH00094: Command line: '/usr/sbin/apache2' [Sat Nov 15 12:42:04.023659 2014] [mpm_event:notice] [pid 4298:tid 3074935424] AH00491: caught SIGTERM, shutting down [Sat Nov 15 12:42:04.248193 2014] [so:warn] [pid 4409:tid 3074857600] AH01574: module wsgi_module is already loaded, skipping [Sat Nov 15 12:42:04.252825 2014] [mpm_event:notice] [pid 4410:tid 3074857600] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations [Sat Nov 15 12:42:04.252860 2014] [core:notice] [pid 4410:tid 3074857600] AH00094: Command line: '/usr/sbin/apache2' 

使用ifconfig

 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:127.0.0.2 PtP:127.0.0.2 Bcast:0.0.0.0 Mask:255.255.255.255 inet6 addr: 2a02:4780:1:1::1:1f88/128 Scope:Global UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 RX packets:20113 errors:0 dropped:0 overruns:0 frame:0 TX packets:9810 errors:0 dropped:3 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:23659654 (23.6 MB) TX bytes:917246 (917.2 KB) venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:10.224.2.128 PtP:10.224.2.128 Bcast:10.224.2.128 Mask:255.255.255.255 UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 

当我去http://31.220.49.197 apache不为我服务的Django应用程序。 当我做service apache2 restart一切顺利好我在做什么错了? 这个configuration适用于我的其他应用程序。

我遇到同样的问题,但幸运的是,在深入Apache设置后,我能够解决这个问题。

这里是我的Apacheconfiguration文件,即000-default.conf ,它服务于默认页面,而不是我的应用程序。 注*:下面的示例在OP apacheconfiguration的帮助下显示。

 <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg. # It is also possible to configure the loglevel for particular # modules, eg #LogLevel info ssl:warn ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined # For most configuration files from conf-available/, which are # enabled or disabled at a global level, it is possible to # include a line for only one particular virtual host. For example the # following line enables the CGI configuration for this host only # after it has been globally disabled with "a2disconf". #Include conf-available/serve-cgi-bin.conf </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] ServerName 31.220.49.197 WSGIDaemonProcess ts threads=25 WSGIProcessGroup ts Alias /static /home/email-validator/static WSGIScriptAlias / /home/email-validator/index.wsgi # Set access permission <Directory /> Allow from all Require all granted </Directory> </VirtualHost> 

而在注释掉80端口的默认虚拟主机设置后,解决了我的问题, 虽然我们仍然得到相同的错误日志:)

这意味着注释掉或删除整个默认/第一<VirtualHost *:80>部分将解决问题。

我目前正在使用Ubuntu 14.4,并从12.4升级后引发此问题。