Installed Apache and the default web root was /var/www I wanted to change the cgi-bin to somewhere within the /var/www but I cannot. It only works at /usr/lib/cgi-bin.

I even tried it with putting a webroot directory in my home directory with a cgi-bin in it and made the changes accordingly in the conf. but the only way it works is when cgi-bin settings point to /usr/lib/cgi-bin.

VirtualHost:

<VirtualHost *:80>
   ServerAdmin webmaster@localhost

    #DocumentRoot /var/www
    DocumentRoot /home/aj/public_html

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    #<Directory /var/www/>
    <Directory /home/aj/public_html/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all  
            AddHandler mod_python .py
            PythonHandler mod_python.publisher
            PythonDebug On
    </Directory>

    ScriptAlias /cgi-bin/ /home/aj/public_html/cgi-bin/
    #ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    #<Directory /usr/lib/cgi-bin/>
    <Directory /home/aj/public_html/cgi-bin/>
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>

Apache log has this error:

script not found or unable to stat: /home/aj/public_html/cgi-bin

Some more info:

After doing a " ps -AF | grep ap" command I got the result back and I think Apache processes are running either as root or www-data. Here is the dump:

root     22762     1  0  8543  8952   0 00:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 22764 22762  0  8669  5928   0 00:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 22765 22762  0  8543  5152   0 00:30 ?        00:00:00 /usr/sbin/apache2 -k start
www-data 22766 22762  0  8669  5928   0 00:30 ?        00:00:00 /usr/sbin/apache2 -k start

Please help. Thanks.

link|improve this question

62% accept rate
2  
Please include relevant portions of your config files. – heavyd Aug 11 '10 at 3:37
Done so. Sorry about that. – sabertooth Aug 11 '10 at 4:18
Don't work means 404 or downloading scripts instead of runing them? – naugtur Aug 11 '10 at 13:31
404. File not found. – sabertooth Aug 11 '10 at 13:47
feedback

3 Answers

If the user account under which Apache is running (guest? nobody?) does not have access to /home/aj/public/cgi-bin then you would see that error.

Please examine the User and Group settings in the httpd.conf, and also examine the output of this command:

ls -ld /home/aj /home/aj/public_html /home/aj/public_html/cgi-bin

Would the Apache user be able to see the cgi-bin directory?

In what way does using e.g. /var/www/cgi-bin not work?
Was there some error message on startup, or did you see an error in the browser when sending a request to a script?

Possibly you have the same problem with /var/www as with your home directory; namely that the Apache process does not have access to that folder.

Note this is all conjecture until we know what user accounts and permissions are in effect.

link|improve this answer
I have edited the post above to show you the processes and users related to those. It does not work means, it will give me a 404, file not found error. – sabertooth Aug 11 '10 at 12:52
/var/www works as in I can see the python cgi working. /home/aj/public_html does not work. How do I change the user. I think even if Apache is running as root, there should be a problem for root to access aj user. – sabertooth Aug 12 '10 at 1:26
Moreover, I see that php files and html files are working. it is just python cgi files that are giving 404 – sabertooth Aug 12 '10 at 1:29
I could run Apache as my own user 'aj' but still no luck. – sabertooth Aug 12 '10 at 2:03
feedback

If cou are profficiend with strace, I suggest you run non forked instance of httpd through strace and see why errors appear. Strace will tell you if it's permission problem or wrong path.

link|improve this answer
feedback
up vote 0 down vote accepted

Got it!

PythonHandler mod_python.publisher 

needs to be

PythonHandler mod_python.cgihandler

Then you can run Python as CGI.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.