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
Bhuvan raj
  • 413
  • 3
  • 8
  • 17
  • 1
    Don't type `{}`. Click on the button that shows the `{}` icon. – S.Lott May 03 '11 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}` – AJ. May 03 '11 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` – Bhuvan raj May 03 '11 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... – AJ. May 03 '11 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?? – Bhuvan raj May 03 '11 at 18:30
  • "By the way i can run cgi programs written in python right?? " Please search for "CGI Python" here on Stack Overflow. This question has been asked (and answered) many, many times. – S.Lott May 03 '11 at 18:39
  • @AJ: You don't need to post status in the comments, either. The changes are pretty easy to spot without status updates. – S.Lott May 03 '11 at 19:11

1 Answers1

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

AJ.
  • 27,586
  • 18
  • 84
  • 94