Error in starting apache2 server while configuring for python

大憨熊 提交于 2019-12-11 04:46:14

问题


Hello i'm trying to configure apache2 server for python, i used this command to install 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

edited the default file to:

<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>

later i used this command:

sudo /etc/init.d/apache2 restart

i got an error:

* 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

when i tried to see what's the link that's present in mod_python.load using cat command i got LoadModule python_module / usr/lib/apache2/modules/mod_python.so

please help me out.

Continued.. Now i'm getting a new error Sir, i have placed a file hello.py having code

#!/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>'

in a folder called cgi-bin in /var/www when i run this on apache2 using

http://localhost/cgi-bin/hello.py

i'm getting this error

The requested URL /cgi-bin/hello.py was not found on this server.
Apache/2.2.14(Ubuntu)Server at localhost Port 80

回答1:


It looks like there is a space between the leading / and the rest of the path to the module. Is there? If so, remove the space and try again...



来源:https://stackoverflow.com/questions/5873534/error-in-starting-apache2-server-while-configuring-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!