Skip to content

Setting up a Python-CGI – Appendix

9. December 2013

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:

  1. Make the new configuration file:
     gedit /home/user/cgi-projects/mycgi/mycgi_http.conf
  2. Add the following lines in there:
    #<VirtualHost *:80>
     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!

  3. Symlink this file to Apache2:
     sudo ln -s /home/user/cgi-projects/mycgi/mycgi_http.conf /etc/apache2/conf.d/mycgi_http.conf
  4. Restart Apache2:
     sudo /etc/init.d/apache2 restart
  5. 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!

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: