Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 356457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T12:06:49+00:00 2026-05-12T12:06:49+00:00

In bash, what is the simplest way to configure lighttpd to call a local

  • 0

In bash, what is the simplest way to configure lighttpd to call a local python script while passing any query string or name-value pairs included with the URL as a command line option for the local python app to parse?

Example:
www.myapp.com/sendtopython/app1.py?Foo=Bar
results in the following occurring on the system. 
>python app1.py Foo=Bar

www.myapp.com/sendtopython/app2.py?-h
results in the following occurring on the system. 
>python app2.py –h

Here is an example lighttpd install and config script.

#!/bin/bash
# Install and configure web console managed by lighttpd
# Suggested Amazon EC2 AMI : ami-0d729464
#
# The console installed into /opt/web-console and 
# available on the http://_the_server_dns_/web-console

set -e -x
export DEBIAN_FRONTEND=noninteractive

function die()
{
    echo -e "$@" >> /dev/console
    exit 1
}

apt-get update && apt-get upgrade -y
apt-get -y install python
apt-get -y install unzip
apt-get -y install lighttpd

# web directory defaults to /var/www. 
WEBDIR=/var/www/logs
mkdir $WEBDIR || die "Cannot create log directory."

PYTHON=`which python`
echo $?
if [ ! $? ]
then
echo "Python interpreter not installed or not found in system path!!!" >> /dev/console
echo "Exiting setup-instance..."
exit 1
fi

#Download web-console 
FILE_DOWNLOAD_URL=http://downloads.sourceforge.net/web-console/web-console_v0.2.5_beta.zip
wget $FILE_DOWNLOAD_URL -O web-console.zip || die "Error downloading file web-console.zip"

# Install the web-console
INSTALL_DIR=/opt/web-console

mkdir $INSTALL_DIR
unzip -u -d $INSTALL_DIR web-console.zip || die "Error extracting web-console.zip"
chown www-data:www-data $INSTALL_DIR

# Configure lighttpd
cat > $INSTALL_DIR/webconsole.conf <<EOF
server.modules  += ( "mod_cgi" )
alias.url       += ( "/web-console/wc.pl" => "/opt/web-console/wc.pl" )
alias.url       += ( "/web-console/" => "/opt/web-console/wc.pl" )
\$HTTP["url"] =~ "^/web-console/" {
        cgi.assign = ( ".pl" => "/usr/bin/perl" )
}
EOF

ln -s $INSTALL_DIR/webconsole.conf /etc/lighttpd/conf-enabled/
/etc/init.d/lighttpd force-reload

exit 0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T12:06:49+00:00Added an answer on May 12, 2026 at 12:06 pm

    Mh, for one thing I wouldn’t mess with the install script, but run it once and then edit the resulting lighttpd configuration file (webconsole.conf in your case).

    You then need to register Python scripts for CGI, like is done for Perl in the install script. You could add a line

    cgi.assign = ( ".py" => "/usr/bin/python" )
    

    under the corresponding .pl line which would make Python another CGI option for the /web-console/ path (look up the lighttpd docs if you want to register .py as CGI in any path).

    Then, your Python CGI script app1.py, app2.py, … have to comply to the CGI spec, which if I recall correclty passes URL parameters as environment variables. So you cannot simply use sys.argv. I’m sure there is a Python module that does the parameter extraction for you. (In Perl, Lincoln Stein’s CGI module is capable of both env and command line args, but I’m not sure about Python’s).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to collect string values in a bash script. What's the simplest way
Within a bash script, what would be the simplest way to verify that a
#!/bin/bash #James Kenaley 20120513 #Server Monitor Script while read -r name ip content do
My bash-script looks as following: echo "Description:" while [ $finishInput -eq 0 ]; do
What is the simplest/best way to ensure only one instance of a given script
What's the simplest way in Ubuntu 11.10 to programmatically guide (either from Bash or
My bash script call a php file #!/bin/bash data=$(./getconfig.php) The file getconfig.php is: #!/usr/bin/env
#!/bin/bash echo SCRIPT: $0 echo Enter Customer Order Ref (e.g. 100018) read P_CUST_ORDER_REF echo
In Bash, how do I declare a local integer variable, i.e. something like: func()
What's the simplest way to print all matches (either one line per match or

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.