1

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
7
  • 1
    Don't type {}. Click on the button that shows the {} icon. Commented May 3, 2011 at 17:52
  • Can you cat /etc/apache2/mods-enabled/mod_python.load and add the output to your question? Also, you don't have to do that symlink mess yourself...just run a2enmod ${modname} Commented May 3, 2011 at 17:56
  • sorry i'm new didn't know how to show code snippet, well i did the command cat over the mod_python.load this is what i got: LoadModule python_module / usr/lib/apache2/modules/mod_python.so Commented May 3, 2011 at 18:01
  • 1
    @Bhuvan raj - 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... Commented May 3, 2011 at 18:19
  • oh ya, there was an space, my bad! i think this must be the height of stupidness you would have ever come across! i'm really sorry for your time :-/ thanks a ton its working now :) :) By the way i can run cgi programs written in python right?? Commented May 3, 2011 at 18:30

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.