为python配置时启动apache2服务器时出错
您好,我正在尝试为python配置apache2服务器,我使用以下命令安装apache2:为python配置时启动apache2服务器时出错,python,apache2,mod-python,Python,Apache2,Mod Python,您好,我正在尝试为python配置apache2服务器,我使用以下命令安装apache2: sudo apt-get install apache2 cd /etc/apache2/mods-enabled/ sudo ln -s ../mods-available/mod_python.load mod_python.load cd /etc/apache2/sites-available/ sudo gedit default 将默认文件编辑为: <Directory /var/ww
sudo apt-get install apache2
cd /etc/apache2/mods-enabled/
sudo ln -s ../mods-available/mod_python.load mod_python.load
cd /etc/apache2/sites-available/
sudo gedit default
将默认文件编辑为:
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride AuthConfig
Order allow,deny
allow from all
AddHandler mod_python .py
PythonHandler mod_python.publisher
PythonDebug On
# Uncomment this directive is you want to see apache2's
# default start page (in /apache2-default) when you go to /
#RedirectMatch ^/$ /apache2-default/
</Directory>
我有一个错误:
* Starting web server apache2 apache2: Syntax error on line 204 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/mod_python.load: LoadModule takes two arguments, a module name and the name of a shared object file to load it from
当我试图使用cat命令查看mod_python.load中的链接时,我得到了LoadModule python_module/usr/lib/apache2/modules/mod_python.so
请帮帮我
继续。。
现在我得到了一个新的错误
先生,我放了一个文件hello.py,里面有代码
#!/usr/bin/python
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'
看起来在模块的前导/后导路径和其余路径之间有一个空格。有?如果是,请删除空格并重试…不要键入
{}
。单击显示{}
图标的按钮。您能否cat/etc/apache2/mods enabled/mod_python.load
并将输出添加到您的问题中?另外,您不必自己做符号链接混乱…只需运行a2enmod${modname}
抱歉,我是新手,不知道如何显示代码段,我在mod_python.load上执行了cat命令,这是我得到的:LoadModule python_module/usr/lib/apache2/modules/mod_python.so
@Bhuvan raj-看起来在前面的/
和模块的其余路径之间有一个空格。有?如果是这样,请删除该空间并重试…哦,是的,有一个空间,我的坏!我想这一定是你遇到的最愚蠢的时刻了!我真的很抱歉占用您的时间:-/非常感谢它现在可以工作了:-)顺便说一下,我可以运行用python编写的cgi程序,对吗??
#!/usr/bin/python
print "Content-type:text/html\r\n\r\n"
print '<html>'
print '<head>'
print '<title>Hello Word - First CGI Program</title>'
print '</head>'
print '<body>'
print '<h2>Hello Word! This is my first CGI program</h2>'
print '</body>'
print '</html>'
The requested URL /cgi-bin/hello.py was not found on this server.
Apache/2.2.14(Ubuntu)Server at localhost Port 80