I want to deploy my Django project to EC2 server. I installed mod_wsgi.
我想将我的Django项目部署到EC2服务器。我安装了mod_wsgi。
And made configuration like in the tutorial of django.
并在django的教程中进行了配置。
I am getting the following:
我得到以下内容:
Invalid command 'WSGIScriptAlias', perhaps misspelled or defined by a module not included in the server configuration
What is the reason? mod_wsgi is not installed correctly?
是什么原因? mod_wsgi安装不正确?
LoadModule wsgi_module libexec/httpd/mod_wsgi.so
LoadModule alias_module libexec/httpd/mod_alias.so
WSGIScriptAlias / /usr/local/apache2/htdocs/mysite/mysite/wsgi.py
WSGIPythonPath /usr/local/apache2/htdocs/mysite/mysite
<Directory /path/to/mysite.com/mysite>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
4 个解决方案
#1
15
The error specifically indicates that mod_wsgi is not being loaded into Apache.
该错误明确指出mod_wsgi未加载到Apache中。
In what file is:
在什么文件中:
LoadModule wsgi_module libexec/httpd/mod_wsgi.so
Did you enable the mod_wsgi module with appropriate Linux distro management command so that it will be loaded if you used distro binary packages for mod_wsgi?
您是否使用适当的Linux发行版管理命令启用了mod_wsgi模块,以便在使用mod_wsgi的发行版二进制包时加载它?
#2
39
The problem is that mod_wsgi
is not installed properly.
问题是mod_wsgi没有正确安装。
Solution (using Apache 2):
解决方案(使用Apache 2):
-
install Apache:
安装Apache:
$ sudo apt-get install apache2
-
install
libapache2-mod-wsgi
:安装libapache2-mod-wsgi:
$ sudo apt-get install libapache2-mod-wsgi
And this should work fine.
这应该工作正常。
#3
1
I just encountered the very same issue on openSUSE 12.2, with apache 2.2.
我刚刚在openSUSE 12.2上遇到了与apache 2.2相同的问题。
Even if wsgi is installed, it is a good idea to check if it has been activated. What I mean is this:
即使安装了wsgi,最好还是检查它是否已被激活。我的意思是:
#outputs a list of registered modules
/usr/sbin/httpd2 -M
If wsgi_module (shared)
does not appear, add wsgi
to the variable APACHE_MODULES
, inside the file /etc/sysconfig/apache2
如果没有出现wsgi_module(shared),请将wsgi添加到文件/ etc / sysconfig / apache2中的变量APACHE_MODULES中
This way I could avoid altogether the line LoadModule
from httpd.conf.
这样我就可以完全避免来自httpd.conf的LoadModule行。
#4
0
just to add, How I solved my problem if you don't know the location of the modules just search for them
只是添加,如果你不知道模块的位置只是搜索它们,我如何解决我的问题
locate mod_alias.so
then you may get output like
然后你可能得到输出
/usr/lib/apache2/modules/mod_alias.so
then you can add that location in your config file
然后你可以在配置文件中添加该位置
LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so
#1
15
The error specifically indicates that mod_wsgi is not being loaded into Apache.
该错误明确指出mod_wsgi未加载到Apache中。
In what file is:
在什么文件中:
LoadModule wsgi_module libexec/httpd/mod_wsgi.so
Did you enable the mod_wsgi module with appropriate Linux distro management command so that it will be loaded if you used distro binary packages for mod_wsgi?
您是否使用适当的Linux发行版管理命令启用了mod_wsgi模块,以便在使用mod_wsgi的发行版二进制包时加载它?
#2
39
The problem is that mod_wsgi
is not installed properly.
问题是mod_wsgi没有正确安装。
Solution (using Apache 2):
解决方案(使用Apache 2):
-
install Apache:
安装Apache:
$ sudo apt-get install apache2
-
install
libapache2-mod-wsgi
:安装libapache2-mod-wsgi:
$ sudo apt-get install libapache2-mod-wsgi
And this should work fine.
这应该工作正常。
#3
1
I just encountered the very same issue on openSUSE 12.2, with apache 2.2.
我刚刚在openSUSE 12.2上遇到了与apache 2.2相同的问题。
Even if wsgi is installed, it is a good idea to check if it has been activated. What I mean is this:
即使安装了wsgi,最好还是检查它是否已被激活。我的意思是:
#outputs a list of registered modules
/usr/sbin/httpd2 -M
If wsgi_module (shared)
does not appear, add wsgi
to the variable APACHE_MODULES
, inside the file /etc/sysconfig/apache2
如果没有出现wsgi_module(shared),请将wsgi添加到文件/ etc / sysconfig / apache2中的变量APACHE_MODULES中
This way I could avoid altogether the line LoadModule
from httpd.conf.
这样我就可以完全避免来自httpd.conf的LoadModule行。
#4
0
just to add, How I solved my problem if you don't know the location of the modules just search for them
只是添加,如果你不知道模块的位置只是搜索它们,我如何解决我的问题
locate mod_alias.so
then you may get output like
然后你可能得到输出
/usr/lib/apache2/modules/mod_alias.so
then you can add that location in your config file
然后你可以在配置文件中添加该位置
LoadModule alias_module /usr/lib/apache2/modules/mod_alias.so