In my previous post, I demonstrated how you can set up a simple Python-CGI.
There, we changed the default setup and made our CGI accessible directly at:
But maybe you don’t want to change the default setting or want to host a bunch of applications. Then it is necessary to make it accesible with a link like:
When you already followed my previous post, you’ve got a running Python-CGI setup (cgi-bin, html).
Making this also accessible in our favoured syntax is really pretty easy. We just have to define a new configuration file (mycgi_http.conf) and have to symlink this file to Apache2 (/apache2/conf.f)
Let’s do it:
- Make the new configuration file:
- Add the following lines in there:
ScriptAlias /mycgi/cgi-bin /home/user/cgi-projects/mycgi/cgi-bin
Alias /mycgi /home/user/cgi-projects/mycgi/html/
I made it deliberately simple, but you could make it also as complex as in the previous example! But I think you can see the significant difference!
- Symlink this file to Apache2:
sudo ln -s /home/user/cgi-projects/mycgi/mycgi_http.conf /etc/apache2/conf.d/mycgi_http.conf
- Restart Apache2:
sudo /etc/init.d/apache2 restart
- Test it, finally: http://localhost/mycgi
When you have done everything correctly you should see the same index-file as in the previous example! Always remember to replace ‘user’ with your login!