bash에서 지역 python 스크립트를 호출하여 로컬 Python 응용 프로그램의 구문 분석을위한 명령 줄 옵션으로 URL에 포함 된 쿼리 문자열이나 이름 - 값 쌍을 전달하면서 lighttpd를 구성하는 가장 간단한 방법은 무엇입니까?bash에서 lighttpd가 특정 URL을 기반으로 로컬 파이썬 스크립트를 호출하도록 구성하는 가장 간단한 방법은 무엇입니까?
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
다음은 lighttpd 설치 및 구성 스크립트의 예입니다.
#!/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 "[email protected]" >> /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
왜 설치 스크립트가 표시됩니까? 그게 무슨 상관이야? –
서버를 계속 실행하지 않고 필요할 때 EC2 인스턴스를 다시 빌드합니다. 내가 작업하고있는 환경에 대한 의사 소통을 돕기위한 스크립트가 포함되었습니다. – Chris