Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have two servers, one in production and one for development.

The production server is Solaris, dev is FreeBSD. Because of this, python is installed in different directories.

I'm using Python right now for making CGI scripts, and needing to remember to swap my hashbangs when I copy from dev to production is a little annoying (Same issue for SVN updates depending on which server I'm comitting from).

Is there a way to configure apache so that I no longer need to hashbangs? Like, if it would lauch python and supply the CGI script for it? Might be a bit of a stretch, but no harm in asking

share|improve this question

3 Answers 3

up vote 0 down vote accepted

The following snippet should work:

ScriptAlias /python-cgi /path/to/python
Action python-cgi /python-cgi
AddHandler python-cgi .py

To understand what these three lines actually do, you should read the respective documentation sections:

share|improve this answer
    
This is the best solution, though not the one I went with –  RandomInsano May 23 '10 at 20:23

Not exactly what you're looking for, since the solution has nothing to do with Apache, but try setting your hashbang to:

#!/usr/bin/env python

And then for the user that runs Apache on each machine make sure that Python is referenced in the user's path such that the /usr/bin/env python command runs the right version of Python.

share|improve this answer

you could always create a symlink to python wherever you're more used to setitng your hashbang...

share|improve this answer
    
That's exactly what I ended up doing :) There's now a link at /opt/csw/bin/python on the FreeBSD system –  RandomInsano May 23 '10 at 20:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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