page_header

dinsdag 10 januari 2012

Enable CGI

Before enabling CGI I implemented a HTML redirect along these lines in the root of my public_html folder. Any user is now automatically forwarded to the file basics.html in the directory xhtml_css under cheat.

Created directory cgi-bin under my public html directory;
- mkdir ~/public_html/cgi-bin

To allow the execution of programs in the cgi-bin directory under public_html I added the following section in the configuration file /etc/apache2/mods-enabled/userdir.conf

        <Directory /home/*/public_html/cgi-bin/>
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                SetHandler cgi-script
                Order allow,deny
                Allow from all
        </Directory>

Next I restarted Apache;
- sudo service apache2 restart

To test cgi I first installed Ubuntu's development tools
- sudo apt-get install build-essential

created a small C test project in ~/dev/temp. I used the "Hello world" example from here.
- gcc test.c -o test.cgi
- cp test.cgi ~/public_html/cgi-bin

After delivering the binary I was able to access the functionality on http://192.168.1.249/~hans/cgi-bin/test.cgi

Great stuff!

Geen opmerkingen:

Een reactie posten